[New-bugs-announce] [issue19055] Regular expressions: * does not match as many repetitions as possible.

Jason Stumpf report at bugs.python.org
Fri Sep 20 00:28:43 CEST 2013


New submission from Jason Stumpf:

>>> re.match('(a|ab)*',('aba')).group(0)
'a'

According to the documentation, the * should match as many repetitions as possible.  2 are possible, it matches 1.

Reversing the order of the operands of | changes the behaviour.

>>> re.match('(ab|a)*',('aba')).group(0)
'aba'

----------
messages: 198116
nosy: Jason.Stumpf
priority: normal
severity: normal
status: open
title: Regular expressions: * does not match as many repetitions as possible.
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19055>
_______________________________________


More information about the New-bugs-announce mailing list