[issue17257] re module shows unexpected non-greedy behavior when using groups

2013-02-21 Thread Hendrik Lemelson
Hendrik Lemelson added the comment: Thank you for clarifying this. While it still not seems really intuitive to me I can handle the behavior. To summarize: It is not possible with re to have an optional ({0,1}) group that contains further subgroups, because re considers (0,0) to already fulfil

[issue17257] re module shows unexpected non-greedy behavior when using groups

2013-02-20 Thread Tim Peters
Tim Peters added the comment: This is how it's supposed to work: Python's re matches at the leftmost position possible, and _then_ matches the longest possible substring at that position. When a regexp _can_ match 0 characters, it will match starting at index 0. So, e.g., >>> re.search('(a

[issue17257] re module shows unexpected non-greedy behavior when using groups

2013-02-20 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- versions: +Python 3.2, Python 3.3, Python 3.4 ___ Python tracker ___ ___ Python-bugs-list mailing lis

[issue17257] re module shows unexpected non-greedy behavior when using groups

2013-02-20 Thread Hendrik Lemelson
New submission from Hendrik Lemelson: When using the Python 2.7.3 re module, it shows a strange behavior upon the use of quantifiers together with groups: >>> re.search('(a*)', 'ct').groups() ('',) >>> re.search('(a+)', 'ct').groups() ('',) >>> re.search('(a{0,5})', 'ct').groups