[New-bugs-announce] [issue34048] Bad behavior of re.IGNORECASE

Jan Švec report at bugs.python.org
Wed Jul 4 16:41:58 EDT 2018


New submission from Jan Švec <honza.svec at gmail.com>:

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"

----------
components: Regular Expressions
messages: 321062
nosy: Jan Švec, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: Bad behavior of re.IGNORECASE
type: behavior
versions: Python 2.7, Python 3.4, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34048>
_______________________________________


More information about the New-bugs-announce mailing list