Issue 34048: Bad behavior of re.IGNORECASE
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:02 | admin | set | github: 78229 |
| 2018-07-04 20:45:13 | Jan Švec | set | status: open -> closed resolution: not a bug messages: + msg321063 stage: resolved |
| 2018-07-04 20:41:58 | Jan Švec | create | |