Skip to content

Allow or forbid duplicated group names #53

@nitely

Description

@nitely

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions