New submission from Wayne Davison :
There is an inconsistency in re.sub() when substituting at the end of a string
using a prior match with a '*' qualifier: the substitution now occurs twice.
For example:
txt = re.sub(r'\s*\Z', "\n", txt)
This should work
Wayne Davison added the comment:
This is not the same thing because the match is anchored, so it is not adjacent
to the prior match -- it is the same match. I think that r'\s*\Z' should behave
the same way as r'\s*x' due to the anchor point. The current behavior is
Wayne Davison added the comment:
Another argument in favor of this being a bug, this does not exhibit the same
doubling:
txt = ' test'
txt = re.sub(r'^\s*', '^', txt)
That always substitutes once.
--
___
Python tra
Wayne Davison <4way...@gmail.com> added the comment:
Can this bug please be reopened and fixed? This is an anchored substitution,
and so should never match more than once.
--
nosy: +4wayned
___
Python tracker
<https://bugs.python.org/i