[issue29015] re slashes

Serhiy Storchaka report at bugs.python.org
Mon Dec 19 11:02:01 EST 2016


Serhiy Storchaka added the comment:

There is a problem with your replacement template. Python string literal '\\' is Python string containing a single backslash character. But backslash has special meaning in a replacement template, it starts escapes and backreferences. For using a literal backslash, it should be escaped: r'\\' or '\\\\'.

>>> re.sub(pat, r'\\', path)
'd:\\temp\\'

----------
nosy: +serhiy.storchaka
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

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


More information about the Python-bugs-list mailing list