Debugging Regular Expressions (RegEx)
Wednesday December 31, 2008
Mastering regular expressions (aka regex) is one of the more challenging areas of programming. Using regex falls into two parts: pattern matching and exclusions. Pattern matching is by far the easiest - you simply derive the pattern from the sample that you would match. It is, however, much harder to match a pattern and only that pattern - excluding false positives.
A major help in controlling regular expressions is Kodos, a regular expression tester written in Python. This is good for when you have a regex to test, but you can expedite the process even further by ensuring you test well-developed regular expressions to begin with. Check out the following guides for developing regular expressions that work well the first time around:
A major help in controlling regular expressions is Kodos, a regular expression tester written in Python. This is good for when you have a regex to test, but you can expedite the process even further by ensuring you test well-developed regular expressions to begin with. Check out the following guides for developing regular expressions that work well the first time around:

Comments
Yes, Kodos is *such* a lifesaver!
In fact, one of my big unfulfilled wishes is to build an extension for Kodos that would work on pyparsing grammars rather than regular expressions…