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.

Author serhiy.storchaka
Recipients ezio.melotti, mrabarnett, serhiy.storchaka
Date 2017-12-13.18:28:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Currently re.sub() replaces empty matches only when not adjacent to a previous match. This makes it inconsistent with re.findall() and re.finditer() which finds empty matches adjacent to a previous non-empty match and with other RE engines.

Proposed PR makes all functions that makes repeated searching (re.split(), re.sub(), re.findall(), re.finditer()) mutually consistent.

The PR change the behavior of re.split() too, but this doesn't matter, since it already is different from the 3.6 behavior.

BDFL have approved this change.

This change doesn't break any stdlib code. It is expected that it will not break much third-party code, and even if it will break some code, it can be easily rewritten. For example replacing re.sub('(.*)', ...) (which now matches an empty string at the end of the string) with re.sub('(.+)', ...) is an obvious fix.
Date User Action Args
2017-12-13 18:28:38serhiy.storchakasetrecipients: + serhiy.storchaka, ezio.melotti, mrabarnett
2017-12-13 18:28:38serhiy.storchakasetmessageid: <>
2017-12-13 18:28:37serhiy.storchakalinkissue32308 messages
2017-12-13 18:28:37serhiy.storchakacreate