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

Backreferences to non-participating groups are handled incorrectly #26

Open
jaynetics opened this issue Dec 22, 2024 · 1 comment
Open

Comments

@jaynetics
Copy link
Owner

Issue extracted from #21.

E.g. ruby does this:

/\1()/.match?('foo') # => false

but the resulting js regex, with the same source, produces a zero-length match on any string.

@slevithan
Copy link

slevithan commented Dec 22, 2024

A few other examples of regexes that include nonparticipating capturing groups:

  • (\1) - should fail to match
  • (a)|b\1 - should never match the second alternative
  • (?<n>a)|(?<n>)\k<n> - the backreference should not allow matching an empty string as one of the multiplexed options (see No backref multiplexing #28)

Might include a nonparticipating capturing group:

  • (a)?b\1
  • ((a)|b)+\2

Never includes a nonparticipating capturing group:

  • (a?)b\1

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

2 participants