[New-bugs-announce] [issue32319] re fullmatch error with non greedy modifier
Daniel Hrisca
report at bugs.python.org
Thu Dec 14 02:56:47 EST 2017
New submission from Daniel Hrisca <daniel.hrisca at gmail.com>:
Consider this code snippet:
from re import match, fullmatch
pattern = '".+?"'
string = '"hello" "again"'
print(match(pattern, string))
print(fullmatch(pattern, string))
Which prints:
<_sre.SRE_Match object; span=(0, 7), match='"hello"'>
<_sre.SRE_Match object; span=(0, 15), match='"hello" "again"'>
The fullmatch function seems to ignore the non-greedy modifier.
>From the fullmatch docstring I expected that fullmatch is equivalent to:
def fullmatch(pattern, string):
match = re.match(pattern, string)
if match:
if match.start() == 0 and match.end() == len(string):
return match
else:
return None
else:
return None
----------
components: Library (Lib)
messages: 308278
nosy: danielhrisca
priority: normal
severity: normal
status: open
title: re fullmatch error with non greedy modifier
type: behavior
versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32319>
_______________________________________
More information about the New-bugs-announce
mailing list