Help with Regular Expressions
pink at odahoda.de
Wed Aug 10 13:46:59 CEST 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.
Email: pink at odahoda dot de
More information about the Python-list