def matchFirst(string, *args):
 for patternlist in args:
  for pattern in patternlist:
   r = pattern.search(string)
   if (r is not None):
    name = r.group(1)
    return name
 return string

def matchFirst ( string , * args ) : for patternlist in args : for pattern in patternlist : r = pattern . search ( string ) if ( r is not None ) : name = r . group ( 1 ) return name return string
matches against list of regexp and returns first match .