[issue32998] regular expression regression in python 3.7

Serhiy Storchaka report at bugs.python.org
Mon Mar 5 11:09:35 EST 2018


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

This is intentional change.

Prior to 3.7 re.sub() didn't replace empty matches adjacent to a previous non-empty match. In 3.7 it does. Together with other changes this made all four functions that search multiple matches of the pattern (re.findall(), re.finditer(), re.split() and re.sub()) consistent.

In your example the pattern matches not only from " COLLATE" to the end of input string, but an empty string at the end of input string. If you do not want matching an empty string, just remove the '?' qualifier.

----------
nosy: +serhiy.storchaka
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

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


More information about the Python-bugs-list mailing list