slevithan / xregexp

Extended JavaScript regular expressions
http://xregexp.com/
MIT License
3.31k stars 278 forks source link

How do you avoid "Cannot use same name for multiple groups" when the same pattern reference is used twice? #352

Closed matthew-dean closed 1 year ago

matthew-dean commented 1 year ago

I have a pattern like:

{{ident}}?{{interpolated}}(?:{{interpolated}}|{{ident}})+

Then I'm building with XRegExp.build

I do not want nor need named capture groups, but the XRegExp docs say

Allows ({{name}}) as shorthand for (?{{name}})

...and there seems no way to disable this conversion. This results in a SyntaxError: Cannot use same name for multiple groups (?<ident>

Is there any workaround?

matthew-dean commented 1 year ago

Oh, hmm, I see, my interpolated fragment referenced {{ident}} as ({{ident}})