Fix-ing regular expressions
There’s another technique that works for a subset of context-free languages. In my opinion, it is very elegant, and it is at least not painfully slow. The result is available on Hackage: the
rerelibrary. The idea is to treat regular expressions as a proper programming language, and add a constructions which proper languages should have: variables and recursion.
Source: Fix-ing regular expressions, an article by Oleg Grenrus.