Closed
Description
In Regex the unapplySeq method uses m.matches to determine if the regex should extract matching groups. This should instead use m.find(0).
Using m.matches acts as if the pattern were implicitly anchored. Consider
val Re = """(x)""".r
val Re(x) = "xyz"
val Re(y) = "x"
When using a regular expression a user can state explicitly that they want anchoring and the Regex library should not mandate that decision. As an aside this often leads to people surrounding their patterns with ".PTRN." which can turn a nice fast pattern into one with heavy backtracking. See Mastering Regular Expressions by Friedl for details.