Issue 34048: Bad behavior of re.IGNORECASE (original) (raw)
re.sub() is behaving incorrectly, if re.IGNORECASE is used. Tested on 2.7, 3.4 and 3.6. The code follows:
import re
def subst(text): text = re.sub(r"\bnine\b", "niner", text, re.IGNORECASE) return text
print(subst("nine nine nine nine"))
It prints "niner niner nine nine". Without the re.IGNORECASE, the output is correct: "niner niner niner niner"