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

Should the optimizer avoid rewriting to \W? #53

Open
mathiasbynens opened this issue Apr 12, 2017 · 1 comment
Open

Should the optimizer avoid rewriting to \W? #53

mathiasbynens opened this issue Apr 12, 2017 · 1 comment

Comments

@mathiasbynens
Copy link
Contributor

See https://mathiasbynens.be/notes/es6-unicode-regex#impact-i.

Per ES6, /\W/iu was equivalent to /[^0-9a-jl-rt-zA-JL-RT-Z_]/u, and engines implemented it that way.

This was fixed in the spec in June 2016. Now, /\W/iu is equivalent to /[^0-9a-zA-Z_\u{017F}\u{212A}]/u. It has been fixed in the abovementioned engines, too, but some people are still using old versions.

TL;DR: inserting \W into character classes potentially changes the behavior of the regular expression, depending on the engine executing the optimized code.

@DmitrySoshnikov
Copy link
Owner

Yeah, those K, S is a weird use case (bug). Might be an edge case, we'll see. Potentially yeah, will avoid rewriting \W (probably will be behind some option for legacy engines).

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