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

JS group names with same name #2317

Open
elibarzilay opened this issue Aug 5, 2024 · 2 comments
Open

JS group names with same name #2317

elibarzilay opened this issue Aug 5, 2024 · 2 comments

Comments

@elibarzilay
Copy link

Bug Description

Duplicate capture group names are now a thing, would be nice to have them.

Reproduction steps

As seen on that page:

/(?<year>\d{4})-\d{2}|\d{2}-(?<year>\d{4})/;

Expected Outcome

Should work.

Browser

Chrome, and therefore "most browsers" :)

(But not yet in node, so not most of that world, yet.)

@firasdib
Copy link
Owner

firasdib commented Aug 9, 2024

So as long as the groups are in different alternatives, the group name may be repeated? Or is there a more complex rule to implement for this?

@elibarzilay
Copy link
Author

That was it looks like -- that page says:

A more recent feature allows named capturing groups to share names, as long as they belong to different disjunction alternatives and cannot be matched at the same time (see browser compatibility for this).

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

No branches or pull requests

3 participants