[Python-ideas] Proposed convenience functions for re module

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Jul 22 08:17:46 CEST 2009


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?

-- 
Greg



More information about the Python-ideas mailing list