eslint-plugin-optimize-regex icon indicating copy to clipboard operation
eslint-plugin-optimize-regex copied to clipboard

False-positive that produces invalid regular expression

Open EvgenyOrekhov opened this issue 4 years ago • 4 comments

/\]/u is getting optimized to /]/u which produces Parsing error: Invalid regular expression: /]/: Lone quantifier brackets.

EvgenyOrekhov avatar Jul 19 '20 21:07 EvgenyOrekhov

Same issue, /\{.*\}/u.exec("abc{foo}xyz") is optimized to /{.*}/u.exec("abc{foo}xyz") which produces Uncaught SyntaxError: Invalid regular expression: /{.*}/: Lone quantifier brackets.

The u flag disables Annex B extension, and makes regex behave like strict mode. I noticed this problem because require-unicode-regexp recommended u to me.

kasugaiasuka avatar Jun 25 '21 04:06 kasugaiasuka

Please report this issue to the upstream library https://github.com/DmitrySoshnikov/regexp-tree

BrainMaestro avatar Jul 26 '21 11:07 BrainMaestro

Upstream issue: https://github.com/DmitrySoshnikov/regexp-tree/issues/224.

EvgenyOrekhov avatar Jul 26 '21 11:07 EvgenyOrekhov

Great! Once it's fixed, I will be happy to publish an update that includes the fix

BrainMaestro avatar Jul 26 '21 12:07 BrainMaestro