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

Tokens in lookaround should not be added to character classes when interpolating a RegExp #29

Open
slevithan opened this issue Jun 2, 2024 · 0 comments

Comments

@slevithan
Copy link

Example: RegExp.make`[${/(?=a)b/i}]` returns /[ABab]/, even though the a is only part of an assertion and not part of what the regex is capable of matching.

You could make a similar case for RegExp.make`[${/a{0}b/}]`, which returns /[ab]/, but maybe shouldn't include the a since it can't be matched. Same goes for RegExp.make`[${/|b/}]` where the b can never be matched. These cases might be unreasonable, but I think that all of these examples help illustrate the strangeness / non-intuitiveness of the design decision to make RegExp instances interpolated in character classes work this way (even though it's a cool feature).

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

1 participant