New submission from anatoly techtonik:
According to docs, group 0 is equivalent to the whole match, which is not true
for Python.
import re
print( re.sub('aaa', r'__\0__', 'argaaagra') )
arg__ __gra
import re
print( re.sub('(aaa)', r'__\1__', 'argaaagra') )
arg__aaa__gra
See also:
http://www.php.net/manual/en/function.preg-replace.php
http://www.regular-expressions.info/ruby.html
----------
components: Library (Lib)
messages: 184210
nosy: techtonik
priority: normal
severity: normal
status: open
title: \0 in re.sub substitutes to space
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5
_______________________________________
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