Author Hendrik.Lemelson
Recipients Hendrik.Lemelson, ezio.melotti, mrabarnett, pitrou
Date 2013-02-20.17:55:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
When using the Python 2.7.3 re module, it shows a strange behavior upon the use of quantifiers together with groups:

>>>'(a*)', 'caaaat').groups()
>>>'(a+)', 'caaaat').groups()
>>>'(a{0,5})', 'caaaat').groups()
>>>'(a{1,5})', 'caaaat').groups()

Whenever a quantifier is used that allows also zero occurrences, the quantifier loses its greedy behavior. This in my eyes is a defect in the re module. In the following there is another example with nested groups where the quantifier for the outer group even prevents the inner groups to match:

>>>'(a(b*)a)', 'caabbaat').groups()
('aa', '')
>>>'(a(b+)a)', 'caabbaat').groups()
('abba', 'bb')
>>>'(a(b*)a){0,1}', 'caabbaat').groups()
(None, None)
>>>'(a(b+)a){0,1}', 'caabbaat').groups()
(None, None)

It would be great if you could manage to fix this.
Thank you in advance.

Hendrik Lemelson
Date User Action Args
2013-02-20 17:55:44Hendrik.Lemelsonsetrecipients: + Hendrik.Lemelson, pitrou, ezio.melotti, mrabarnett
2013-02-20 17:55:44Hendrik.Lemelsonsetmessageid: <>
2013-02-20 17:55:43Hendrik.Lemelsonlinkissue17257 messages
2013-02-20 17:55:43Hendrik.Lemelsoncreate