![](https://secure.gravatar.com/avatar/72ee673975357d43d79069ac1cd6abda.jpg?s=120&d=mm&r=g)
July 22, 2009
7:22 a.m.
MRAB wrote:
Extend the current re.match and re.search to accept a tuple of patterns:
m = re.match((pattern0, pattern1, pattern2, pattern3), s) if m: print m.group()
Also give the match object an 'index' attribute indicating which pattern matched, so you can do m = re.match((pattern1, pattern2, pattern3, pattern4), s) if m: if m.index == 0: # pattern0 matched elif m.index == 1: # pattern1 matched # etc. -- Greg