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:
- Pastebin.com - Output from terminal
- codepad - Script, confirming behavior (except for re.subn(), which is different on 2.5)
Can someone confirm / deny this behavior on their machine?
EDIT: Realized I should go ahead and post this on the Python bug tracker.
EDIT 2: Issue reported: http://bugs.python.org/msg168909
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…