Help with Regular Expressions
Benjamin Niemann
pink at odahoda.de
Wed Aug 10 07:46:59 EDT 2005
Harlin Seritt wrote:
> Forgive another question here, but what is the 'r' for when used with
> expression: r'\w+...' ?
r'..' or r".." are "raw strings" where backslashes do not introduce an
escape sequence - so you don't have to write '\\', if you need a backslash
in the string, e.g. r'\w+' == '\\w+'.
Useful for regular expression (because the re module parses the '\X'
sequences itself) or Windows pathes (e.g. r'C:\newfile.txt').
And you should append a '$' to the regular expression, because
r"\w+@\w+\.\w+" would match 'foo at example.com-+*junk', too.
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
More information about the Python-list
mailing list