Is there such thing as automated regular expression refactoring?
I'm wondering whether there is an online service or utility that can understand and simplify and/or optimise a regex.
e.g.
^[A-Z][A-Z][0-9][0-9][0-9]$ → ^[A-Z]{2}[0-9]{3}$
(Obviously this is an abstract example)
Regular expressions are automata, you can use an algorithm designed to build deterministic finite automaton, it will refactor the original automaton to a simpler one.
I do not know a programming language implementation but you can get inspired with Nondeterministic finite automaton Wikipedia page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With