[New-bugs-announce] [issue27851] re.sub() bug with IGNORECASE

Dan Wilt report at bugs.python.org
Wed Aug 24 11:57:11 EDT 2016


New submission from Dan Wilt:

Working with re.sub() noted strange behavior with re.I set, seems like a bug. Noted in both Python 2.7.12 and Python 3.5.2, Anaconda custom build (32-bit) on Windows 7.

>>> import re
>>> re.sub('\.', '', '.....')
''
>>> re.sub('\.', '', '.....', re.I)
'...'
>>> re.sub('\.', '', '.....', re.L)
'.'

The first case is the expected behavior, the second and third aren't. Oddly enough,

>>> re.sub('\.', '', '.....', re.L | re.I)
''

MWE file attached (python3)

Thanks, I'm a heavy python user, but not all that advanced - hope this is helpful and I'm not just being stupid.

----------
components: Regular Expressions
files: re_bug.py
messages: 273575
nosy: Dan Wilt, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: re.sub() bug with IGNORECASE
type: behavior
versions: Python 2.7, Python 3.5
Added file: https://bugs.python.org/file44212/re_bug.py

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


More information about the New-bugs-announce mailing list