-
Notifications
You must be signed in to change notification settings - Fork 11
Simplify nested characters classes and expression character classes #574
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Thank you for the rule suggestions! I haven't really used nested character classes yet, but I think the rule is very useful! |
Same. I only used them when writing tests for I'm looking forward to using the We might even want to make a rule for that. If a regex has the |
I was working on
However, the following patterns are not supported yet. I'm wondering whether we should support them with
By the way, I think it would be better to use a separate rule to check patterns that rewrite the following expressions. Because I think it's an optimization problem.
|
I thought for a moment and thought the rule should support them, so I'll change the rule. |
Motivation
The
v
flag added set operation to character classes. These set operations can be simplified in some cases.Description
The rule should apply the following simplifications:
[[abc]]
->[abc]
and[^[abc]]
->[^abc]
and[[^\w&&\d]]
->[^\w&&\d]
: remove trivially nested (expression) character classes.[[abc][def]ghi]
->[abcdefghi]
: always inline non-negated character classes.[a&&[^b]]
->[a--b]
and[[^b]&&a]
->[a--b]
: use subtraction[a--[^b]]
->[a&&b]
: use intersection[[^a]&&[^b]]
->[^ab]
: De MorganThe text was updated successfully, but these errors were encountered: