regular expression

Roy Smith roy at panix.com
Tue Aug 16 07:50:55 EDT 2011


In article <mailman.41.1313479583.27778.python-list at python.org>,
 Chris Rebert <clp2 at rebertia.com> wrote:

> pat = re.compile("^ *(\\([^)]+\\))", re.MULTILINE)

First rule of regexes in Python is to always use raw strings, to 
eliminate the doubled backslashes:

> pat = re.compile(r"^ *(\([^)]+\))", re.MULTILINE)

Is easier to read.



More information about the Python-list mailing list