[issue19964] '?' is always non-greedy
Serhiy Storchaka
report at bugs.python.org
Thu Dec 12 18:29:31 CET 2013
Serhiy Storchaka added the comment:
I don't think the documentation is wrong. re.search() returns first match, and this is empty string at position 0.
>>> import re
>>> re.search('1?', '01')
<_sre.SRE_Match object; span=(0, 0), match=''>
All matches:
>>> list(re.findall('1?', '01'))
['', '1', '']
>>> list(re.finditer('1?', '01'))
[<_sre.SRE_Match object; span=(0, 0), match=''>, <_sre.SRE_Match object; span=(1, 2), match='1'>, <_sre.SRE_Match object; span=(2, 2), match=''>]
----------
nosy: +ezio.melotti, pitrou, serhiy.storchaka
resolution: -> invalid
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19964>
_______________________________________
More information about the Python-bugs-list
mailing list