Simon Willison’s Weblog


Verbose Regular Expressions

11th April 2003

Ned Batchelder describes Verbose Python regular expressions. This is one of the things I’ve known about (as in known that they exist) for ages but have never got around to using. I’ve been working with some pretty heavy regular expressions recently that could really do with the clarity of being defined in verbose format with comments.

PHP also has support for verbose REs, thanks to the excellent pcre functions. Just use the ’x’ modifier as explained on this manual page.

This is Verbose Regular Expressions by Simon Willison, posted on 11th April 2003.

Next: PHP5 and Questioning OOP

Previous: URI Design Resources

Previously hosted at