Extract a sequence of values from the first match found.
Extract a sequence of values from the first match found.
This is useful for allowing you to do a sequence of match & extract operations on a string. For example, see the example below of parsing a date string and pulling out its pieces.
"2012-Q1" match { case "(\\d{4})-(\\d{2})-(\\d{2})".rx(year, month, day) => ... case "(\\d{4})-Q(\\d)".rx(year, quarter) => ... }
There is no convenient way to do this with the libraries that are built into Scala.
Note that there is no checking done to ensure that there is only one match.
Enhanced regex operations that aren't supported by regular Scala
Regex
objects.