[issue10139] regex A|B : both A and B match, but B is wrongly preferred
Χρήστος Γεωργίου (Christos Georgiou)
report at bugs.python.org
Tue Oct 19 09:50:14 CEST 2010
Χρήστος Γεωργίου (Christos Georgiou) <tzot at users.sourceforge.net> added the comment:
As I see it, it's more like:
>>> re.search('a.*c|a.*|.*c', 'abc').group()
producing 'bc' instead of 'abc'. Substitute "(?<=^A)" for "a" and "(?=Z$)" for "c" in the pattern above.
In your example, the first part ('bc') does not match the whole string ('abc'). In my example, the first part ('(?<=^A).*(?=Z$)') matches the whole string ('A***Z').
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10139>
_______________________________________
More information about the Python-bugs-list
mailing list