
July 22, 2009
8:14 a.m.
En Wed, 22 Jul 2009 03:17:46 -0300, Greg Ewing <greg.ewing-F+z8Qja7x9Xokq/tPzqvJg@public.gmane.org> escribió:
Steven D'Aprano wrote:
def multimatch(s, *patterns): """Do a re.match on s using each pattern in patterns, returning the first one to succeed, or None if they all fail.""" for pattern in patterns: m = re.match(pattern, s) if m: return m
How are you supposed to tell which one matched?
m.re contains the matching expression -- Gabriel Genellina