Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow or forbid duplicated group names #53

Open
nitely opened this issue Oct 27, 2019 · 0 comments
Open

Allow or forbid duplicated group names #53

nitely opened this issue Oct 27, 2019 · 0 comments

Comments

@nitely
Copy link
Owner

nitely commented Oct 27, 2019

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)".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant