|Ned Batchelder : Blog | Code | Text | Site|
Reversing regular expressions
» Home : Blog : September 2003
Just when you thought regular expressions were powerful and confusing enough, comes Reversing regular expressions. The idea is that if a match is too hard to make going forward through the string, then reverse the string first, apply a reversed regex to it, and finally reverse the resulting match. Wow.
Update (thanks to Simon, who shows Python for the technique): I forgot to mention that this technique is called "sexeger" ("regexes" backwards, get it?), and here's japhy's authoritative treatise on the subject.