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.

classification
Title: Bad behavior of re.IGNORECASE
Type: behavior Stage: resolved
Components: Regular Expressions Versions: Python 3.6, Python 3.4, Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Jan Švec, ezio.melotti, mrabarnett
Priority: normal Keywords:

Created on 2018-07-04 20:41 by Jan Švec, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg321062 - (view) Author: Jan Švec (Jan Švec) Date: 2018-07-04 20:41
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"
msg321063 - (view) Author: Jan Švec (Jan Švec) Date: 2018-07-04 20:45
Not a bug, it assigns the value of re.IGNORECASE into the count parameter. Sorry
History
Date User Action Args
2022-04-11 14:59:02adminsetgithub: 78229
2018-07-04 20:45:13Jan Švecsetstatus: open -> closed
resolution: not a bug
messages: + msg321063

stage: resolved
2018-07-04 20:41:58Jan Šveccreate