This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Bug in the match function
Type: Stage:
Components: Regular Expressions Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: niemeyer Nosy List: georg.brandl, niemeyer, tim.peters, wojtekwu
Priority: normal Keywords:

Created on 2006-09-09 20:02 by wojtekwu, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg29790 - (view) Author: wojtekwu (wojtekwu) Date: 2006-09-09 20:02
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 
32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for 
more information.
>>> import re
>>> as = re.compile("(a|((a|b)*))")
>>> wynik = as.match("aabaa")
>>> wynik.end()
1
>>> as = re.compile("(((a|b)*)|a)")
>>> wynik = as.match("aabaa")
>>> wynik.end()
5
>>>
msg29791 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-09-09 20:06
Logged In: YES 
user_id=849994

IMHO that's not a bug, since we have a "leftmost
alternative" strategy, not a "longest match".
msg29792 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2006-09-09 22:23
Logged In: YES 
user_id=31435

That's right -- the first ("leftmost") alternative that
matches wins; same as Perl, etc etc.  Closing as Not-A-Bug.
History
Date User Action Args
2022-04-11 14:56:20adminsetgithub: 43957
2006-09-09 20:02:38wojtekwucreate