Open nitely opened 4 years ago
The following code compiles, but the group just contains the last capture:
var m: RegexMatch doAssert "abab".match(re"(?P<foo>ab)(?P<foo>ab)", m) doAssert m.group("foo") == @[2 .. 3] doAssert m.group(0) == @[0 .. 1] doAssert m.group(1) == @[2 .. 3]
So, we can either throw a compile error, same as PCRE, or we can make foo return both group captures. The latter sounds like a nice feature for expressions like "(?P<foo>ab)|(?P<foo>cd)|(?P<foo>ef)".
foo
"(?P<foo>ab)|(?P<foo>cd)|(?P<foo>ef)"
The following code compiles, but the group just contains the last capture:
So, we can either throw a compile error, same as PCRE, or we can make
foo
return both group captures. The latter sounds like a nice feature for expressions like"(?P<foo>ab)|(?P<foo>cd)|(?P<foo>ef)"
.