22 Jul 2009 22 Jul '09
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?