DmitrySoshnikov / regexp-tree

Regular expressions processor in JavaScript
MIT License
400 stars 45 forks source link

Question about Optimization #214

Open coderaiser opened 3 years ago

coderaiser commented 3 years ago

Thank you for a library with such hight quality :). I just integrated regexp-tree into Putout linter, run it on my code, and had seen a strange optimization:

require('regexp-tree').optimize(/[<>=!]/).toString()
'/[!<=>]/'

Could you please tell me is it more optimized regexp or it's a bug?

DmitrySoshnikov commented 3 years ago

Thanks for the feedback! As to the optimization: yes, this seems is a consequence of optimizing character classes, and sorting the chars as a side effect.