gminick <gminick at hacker.pl> writes: > import re > a = "Fuentes Rushdie Marquez" > print re.search("Rushdie|Fuentes", a).group() # returns "Fuentes" > > According to the documentation I suspected it will return "Rushdie" > rather than "Fuentes", but it looks like it returns first part of the > string that matches rather than first part of regular expression. You are assuming that re.search("Rushdie|Fuentes", a) is evaluated like m = re.search("Rushdie", a) if m is None: m = re.search("Fuentes", a) But it doesn't work that way. It works more like: m = None for i in xrange(0, len(a)): s = a[i:] m = re.match("Rushdie|Fuentes", s) if not m is None: break I.e., try to match the expression at the start of the string; if that doesn't work, try matching at the next character, etc.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4