[issue24071] Python 2.7.8, 2.7.9 re.MULTILINE failure

Matthew Barnett report at bugs.python.org
Tue Apr 28 21:38:44 CEST 2015


Matthew Barnett added the comment:

The 4th argument of re.sub is the maximum count (0 means unlimited).

>>> help(re.sub)
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.

The value of re.MULTILINE is 8:

>>> re.MULTILINE
8

therefore it'll perform a maximum of 8 substitutions.

In summary: not a bug.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24071>
_______________________________________


More information about the Python-bugs-list mailing list