Python

  1. Home
  2. Computing & Technology
  3. Python

Python Blog

From Al Lukaszewski, for About.com

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:

Comments

December 31, 2008 at 2:35 pm
(1) Catherine Devlin says:

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…

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Explore Python

About.com Special Features

Python

  1. Home
  2. Computing & Technology
  3. Python

©2009 About.com, a part of The New York Times Company.

All rights reserved.