[issue12078] re.sub() replaces only several matches
Matthew Barnett
report at bugs.python.org
Sat May 14 19:26:53 CEST 2011
Matthew Barnett <python at mrabarnett.plus.com> added the comment:
Argument 4 of re.sub is the maximum number of replacements, NOT flags:
Help on function sub in module re:
sub(pattern, repl, string, count=0, flags=0)
Return the string obtained by replacing the leftmost
non-overlapping occurrences of the pattern in string by the
replacement repl. repl can be either a string or a callable;
if a string, backslash escapes in it are processed. If it is
a callable, it's passed the match object and must return
a replacement string to be used.
re.I is 2, so you're telling it to perform at most 2 replacements.
----------
nosy: +mrabarnett
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12078>
_______________________________________
More information about the Python-bugs-list
mailing list