[issue32308] Replace empty matches adjacent to a previous non-empty match in re.sub()
Matthew Barnett
report at bugs.python.org
Fri Apr 12 15:53:42 EDT 2019
Matthew Barnett <python at mrabarnett.plus.com> added the comment:
Consider re.findall(r'.{0,2}', 'abcde').
It finds 'ab', then continues where it left off to find 'cd', then 'e'.
It can also find ''; re.match(r'.*', '') does match, after all.
It could, in fact, an infinite number of ''.
And what about re.match(r'()*', '')?
What should it do? Run forever? Raise an exception?
At some point you have to make a decision as to what should happen, and the general consensus has been to match once.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32308>
_______________________________________
More information about the Python-bugs-list
mailing list