This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eacousineau
Recipients eacousineau, ezio.melotti, mrabarnett
Date 2012-08-23.00:03:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1345680185.37.0.726682909185.issue15768@psf.upfronthosting.co.za>
In-reply-to
Content
[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)
History
Date User Action Args
2012-08-23 00:03:05eacousineausetrecipients: + eacousineau, ezio.melotti, mrabarnett
2012-08-23 00:03:05eacousineausetmessageid: <1345680185.37.0.726682909185.issue15768@psf.upfronthosting.co.za>
2012-08-23 00:03:04eacousineaulinkissue15768 messages
2012-08-23 00:03:04eacousineaucreate