Why does regex.subgroups work, but using the extractor pattern produces a scala.MatchError

I have what I thought was a working Regex. It is working and returning the right information when I invoke it via .subgroups (lines 10-18 in Scastie link below). However, when I attempt to use the extractor pattern recommendations, it is failing with “scala.MatchError: abcN-008.0 Syz - success (of class java.lang.String)” (lines 20-21).

I have two different values I use to test (lines 7 and 8) to try and isolate where things might be going wrong.

IOW, I don’t understand where I am making a mistake such that the subgroups approach finds it valid but the extractor pattern is clearly throwing an exception. Any guidance on this would be greatly appreciated.

The difference is that the findAllIn method does a search (using the unanchored regex), but using the extractor tries to match the string on the regex (regexes are anchored by default).

This works:

val regexLongOrLat0 = regexLongOrLat.unanchored
val regexLongOrLat0(preDirectional, signedDecimal, postDirectional) =
1 Like