[issue35653] All regular expression match groups are the empty string
Matthew Barnett
report at bugs.python.org
Thu Jan 3 20:13:35 EST 2019
Matthew Barnett <python at mrabarnett.plus.com> added the comment:
Look at the spans of the groups:
>>> import re
>>> re.search(r'^(?:(\d*)(\D*))*$', "42AZ").span(1)
(4, 4)
>>> re.search(r'^(?:(\d*)(\D*))*$', "42AZ").span(2)
(4, 4)
They're telling you that the groups are matching twice (because of the outer *). The first time, they match ('42', 'AZ'); the second time, they match ('', '') at the end of the string.
Not a bug.
----------
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35653>
_______________________________________
More information about the Python-bugs-list
mailing list