slevithan/xregexp

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

matthew-dean opened this issue · 1 comments

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?

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