def matchPatterns(patterns, keys):
 results = []
 if patterns:
  for pattern in patterns:
   prog = re.compile(pattern)
   for key in keys:
    if prog.match(key):
     results.append(key)
 else:
  return None
 return results

def matchPatterns ( patterns , keys ) : results = [ ] if patterns : for pattern in patterns : prog = re . compile ( pattern ) for key in keys : if prog . match ( key ) : results . append ( key ) else : return None return results
returns a subset of the keys that match any of the given patterns parameters: patterns: a list of regular expressions to match keys: a list of keys to search for matches .