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 alegrigoriev
Recipients alegrigoriev
Date 2021-04-03.13:03:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1617454993.35.0.466919552737.issue43714@roundup.psfhosted.org>
In-reply-to
Content
If '\Z' matches as part of a pattern in re.sub() or re.split(), it should consume the end of string, and then '\Z' alone should not match the end of string again.

Current behavior:

Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> print(re.split(r'/?\Z', 'a/b/c/d/'))
['a/b/c/d', '', '']
>>> print(re.sub(r'/?\Z', '-', 'a/b/c/d/'))
a/b/c/d--


Wanted behavior:

>>> print(re.split(r'/?\Z', 'a/b/c/d/'))
['a/b/c/d', '']
>>> print(re.sub(r'/?\Z', '-', 'a/b/c/d/'))
a/b/c/d-
History
Date User Action Args
2021-04-03 13:03:13alegrigorievsetrecipients: + alegrigoriev
2021-04-03 13:03:13alegrigorievsetmessageid: <1617454993.35.0.466919552737.issue43714@roundup.psfhosted.org>
2021-04-03 13:03:13alegrigorievlinkissue43714 messages
2021-04-03 13:03:13alegrigorievcreate