Skip to content

Should the optimizer avoid rewriting to \W? #53

@mathiasbynens

Description

@mathiasbynens

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions