You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Motivation
Due to the lack of set operation for character classes, I wrote regexes like (?!\s)[\w\P{ASCII}] in the past (another example). They can be transformed to use set operations instead. Using set operation not only makes the intent clearer, it's also more performant. I did some performance test a while back, and (?!\s)[\w\P{ASCII}] was about 4x slower than [\w...whatever ranges are equivalent].
Description
Combine single-character lookarounds with character classes in regexes with the v flag. E.g. (?=[x])[y] => [y&&x] and (?![x])[y] => [y--x]. Regexes without the v should not be affected.
If the element after the lookaround is a character set, then the transformation should still be applied. E.g. (?!\s)\P{ASCII} => [\P{ASCII}--\s].
Motivation
Due to the lack of set operation for character classes, I wrote regexes like
(?!\s)[\w\P{ASCII}]
in the past (another example). They can be transformed to use set operations instead. Using set operation not only makes the intent clearer, it's also more performant. I did some performance test a while back, and(?!\s)[\w\P{ASCII}]
was about 4x slower than[\w...whatever ranges are equivalent]
.Description
Combine single-character lookarounds with character classes in regexes with the
v
flag. E.g.(?=[x])[y]
=>[y&&x]
and(?![x])[y]
=>[y--x]
. Regexes without thev
should not be affected.If the element after the lookaround is a character set, then the transformation should still be applied. E.g.
(?!\s)\P{ASCII}
=>[\P{ASCII}--\s]
.Examples
The text was updated successfully, but these errors were encountered: