[issue22760] re.sub does only first 16 replacements if re.S is used
Peter Otten
report at bugs.python.org
Wed Oct 29 16:49:42 CET 2014
Peter Otten added the comment:
This is not a bug; the signature of re.sub() is
sub(pattern, repl, string, count=0, flags=0)
and the fourth argument thus the 'count' delimiting the number of substitutions that you accidentally specify as
>>> import re
>>> re.S
16
I recommend that you use a keyword arg to fix your code:
>>> re.sub('x', 'a', "x"*20, flags=re.S)
'aaaaaaaaaaaaaaaaaaaa'
----------
nosy: +peter.otten
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22760>
_______________________________________
More information about the Python-bugs-list
mailing list