anatoly techtonik added the comment:
Matthew, finally the right answer. Thanks!
Looking further, there is a bug in processing backslashes in raw literal
replacement strings. re.sub ignores raw strings as replacements. This can be
even more confusing for people who look for more advanced equivalent for string
replace().
patt = "aaa"
repl = r"zed \0 org"
print(" aaa ".replace(patt, repl))
import re
print(re.sub(patt, repl, " aaa "))
This gives:
zed \0 org
zed org
With `repl = "zed \0 org"`, the output matches:
zed org
zed org
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue17426>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com