[New-bugs-announce] [issue15768] re.sub() with re.MULTILINE not replacing all occurrences
Eric Cousineau
report at bugs.python.org
Thu Aug 23 02:03:05 CEST 2012
New submission from Eric Cousineau:
[Copying post I made here: http://stackoverflow.com/questions/12082886/bug-in-python-regex-re-sub-with-re-multiline]
I'm noticing some odd behavior in Python's Regex library, and I'm not sure if I'm doing something wrong.
If I run a regex on it using re.sub(), with re.MULTILINE. It seems to only replace the first few occurrences. It replaces all occurrences if I turn off re.MULTILINE, use re.subn(..., count = 0, flags = re.MULTILINE), or compile the regex using re.compile(..., re.MULTILINE).
I am running Python 2.7 on Ubuntu 12.04.
I've posted a random example on:
http://pastebin.com/49SU8Mm2 - Output from terminal
http://codepad.org/2RO2iS4O - Script, confirming behavior (except for re.subn(), which is different on 2.5)
----------
components: Regular Expressions
messages: 168909
nosy: eacousineau, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: re.sub() with re.MULTILINE not replacing all occurrences
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15768>
_______________________________________
More information about the New-bugs-announce
mailing list