tc39 / proposal-regexp-x-mode

BSD 3-Clause "New" or "Revised" License
26 stars 2 forks source link

Working JS library for flag x based on details in the proposal #7

Open slevithan opened 6 months ago

slevithan commented 6 months ago

I recently created the regex package, which is a template tag for regexes as raw strings. Among other features, it always implicitly enables flag x based on details in this proposal (which are fairly limited right now, so I also based it on flag xx from Perl and PCRE).

It always uses flag v (if available) or u implicitly, so it can't be used to test x in Unicode-unaware mode. And since it uses template strings, it doesn't need to worry about ()[]/ in comments (since comments are stripped before passing to the RegExp constructor). But with those caveats, you can use it to test x behavior even for edge cases.

Just for example:

If additional details are clarified in this proposal and they don't match regex's handling, I will update it to stay in line.