[New-bugs-announce] [issue17426] \0 in re.sub substitutes to space

anatoly techtonik report at bugs.python.org
Fri Mar 15 05:39:02 CET 2013


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 <report at bugs.python.org>
<http://bugs.python.org/issue17426>
_______________________________________


More information about the New-bugs-announce mailing list