I think I just built a better mousetrap
-
1. ba((r|a|b|c)|z+)
2. ba((r|(a|(b|c)))|z(z)*)
3. ba([ra-c]|z+)There are 3 major algorithms for converting a state machine to a regular expression. Of these, the cleanest is probably the state-removal method, which I've employed. #1 is the original expression #2 is the expression recreated from a state machine using the state removal method #3 is the result of my new algorithm, based around the state removal method, but with improvements. Instead of building a string expression, I built out an abstract syntax tree for my regex After it is built, I can then do high level analysis and reduction on that expression tree. The result is #3. Woo! I went from not being able to solve this for years to improving on it pretty signficantly.
Real programmers use butterflies