[issue41080] re.sub treats * incorrectly?

Ryan Westlund report at bugs.python.org
Mon Jun 22 14:04:10 EDT 2020


Ryan Westlund <rlwestlund at gmail.com> added the comment:

Sorry, I forgot the pydoc docs don't have as much information as the online
docs.

On Mon, Jun 22, 2020 at 1:54 PM Ezio Melotti <report at bugs.python.org> wrote:

>
> Ezio Melotti <ezio.melotti at gmail.com> added the comment:
>
> This behavior was changed in 3.7: "Empty matches for the pattern are
> replaced only when not adjacent to a previous empty match, so sub('x*',
> '-', 'abxd') returns '-a-b--d-'." [0]
>
> See also bpo-32308 and bpo-25054.
>
>
> [0]: https://docs.python.org/3/library/re.html#re.sub
>
> ----------
> resolution:  -> not a bug
> stage:  -> resolved
> status: open -> closed
> superseder:  -> Replace empty matches adjacent to a previous non-empty
> match in re.sub()
>
> _______________________________________
> Python tracker <report at bugs.python.org>
> <https://bugs.python.org/issue41080>
> _______________________________________
>

----------

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


More information about the Python-bugs-list mailing list