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.
More recent articles
- Not all AI-assisted programming is vibe coding (but vibe coding rocks) - 19th March 2025
- Adding AI-generated descriptions to my tools collection - 13th March 2025
- Notes on Google's Gemma 3 - 12th March 2025