Message308229
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:38 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, ezio.melotti, mrabarnett |
2017-12-13 18:28:38 | serhiy.storchaka | set | messageid: <1513189718.03.0.213398074469.issue32308@psf.upfronthosting.co.za> |
2017-12-13 18:28:37 | serhiy.storchaka | link | issue32308 messages |
2017-12-13 18:28:37 | serhiy.storchaka | create | |
|