[issue13409] Invalid expression error if a regex ends with a backslash

Ezio Melotti report at bugs.python.org
Tue Nov 15 20:16:18 CET 2011


Ezio Melotti <ezio.melotti at gmail.com> added the comment:

You either have to double escape it (once for python and then for the regex engine) or use raw strings:
>>> re.match("\\\\", '\\').group()
'\\'
>>> re.match(r"\\", '\\').group()
'\\'

----------
assignee:  -> ezio.melotti
resolution:  -> invalid
stage:  -> committed/rejected
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13409>
_______________________________________


More information about the Python-bugs-list mailing list