Verbose Regular Expressions
We'll cover the following...
So far you’ve just been dealing with what I’ll call “compact” regular expressions. As you’ve seen, they are difficult to read, and even if you figure out what one does, that’s no guarantee that you’ll be able to understand it six months later. What you really need is inline documentation.
Python allows you to do this with something called verbose regular expressions. verbose regular expression is different from a compact regular expression in two ways:
- Whitespace is ignored. Spaces, tabs, and carriage returns are not matched