[issue41555] re.sub replaces twice

S. Zhang report at bugs.python.org
Sat Aug 15 08:10:48 EDT 2020


S. Zhang <spz1st at gmail.com> added the comment:

Thanks.   But if talking about empty matches, there would be endless empty
matches at the end in such cases.  So in my opinion, [^\.]*$ should match
txt plus the empty match because the greedy rule applies here.

On Fri, Aug 14, 2020 at 10:37 PM Ma Lin <report at bugs.python.org> wrote:

>
> Ma Lin <malincns at 163.com> added the comment:
>
> The re.sub() doc said:
> Changed in version 3.7: Empty matches for the pattern are replaced when
> adjacent to a previous non-empty match.
>
> IMO 3.7+ behavior is more reasonable, and it fixed a bug, see issue25054.
>
> ----------
> nosy: +malin
>
> _______________________________________
> Python tracker <report at bugs.python.org>
> <https://bugs.python.org/issue41555>
> _______________________________________
>

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41555>
_______________________________________


More information about the Python-bugs-list mailing list