New submission from Serhiy Storchaka <[email protected]>:
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.
----------
assignee: serhiy.storchaka
components: Library (Lib), Regular Expressions
messages: 308229
nosy: ezio.melotti, mrabarnett, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Replace empty matches adjacent to a previous non-empty match in re.sub()
type: enhancement
versions: Python 3.7
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue32308>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com