New submission from Alexander Grigoriev <alegrigor...@gmail.com>:
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- ---------- components: Library (Lib) messages: 390124 nosy: alegrigoriev priority: normal severity: normal status: open title: re.split(), re.sub(): '\Z' must consume end of string if it matched type: behavior versions: Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43714> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com