You can use verbose mode to write more readable regular expressions. In this mode:
- Whitespace within the pattern is ignored, except when in a character class or preceded by an unescaped backslash.
- When a line contains a '#' neither in a character class or preceded by an unescaped backslash, all characters from the leftmost such '#' through the end of the line are ignored.
The following two statements are equivalent:
a = re.compile(r"""d + # the integral part
. # the decimal point
d * # some fractional digits""", re.X)
b = re.compile(r"d+.d*")
(Taken from the documentation of verbose mode)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…