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
- We're going to need default hard budget caps on pretty much everything - 3rd October 2026
- OpenAI DevDay 2026 live blog - 29th September 2026
- 2026 in LLMs (so far) - 27th September 2026