Regular Expression Matching Can Be Simple And Fast
swtch.com
swtch.com
Interestingly, if you think in Lisp, it's obvious how much more elegant Thompson's approach is (than a C struct-based state machine), and how you would implement it in Thompson's way with closures.
The clean transform in Thomson's algorithm only works for Regular Languages.
If you use adhoc, you always get the huge version (it probably doesn't matter anyways - it's going to be used once). If you compile, simple version would start constructing the pattern matching graph - as soon as anything not-supported is found, you go back to the big RE. One time cost should not be big if you're already prepared to match many strings (you're using crazy features and compiling that RE explicitely after all - that's going to take long). Optionally a flag could force a specific engine.
Thomson's algorithm would let you could use regular expressions for cases where you would otherwise have never tried.
The O(2^n) worst case only comes from highly ambiguous patterns which are better written in other ways. So this isn't really accurate in practice.
I haven't paid attention to Perl in a while... Perl is kinda like that cute girl that you dated in high school, then had an amicable breakup with when you went off to college. You're always glad to see that she's doing well, but you're off on new things by now.
http://dsource.org/projects/tango/docs/stable/tango.text.Reg...