def _matchReportKeys(reportKeyREs=[], allReportKeys=[]):
matchingReportKeys = []<EOL>for keyRE in reportKeyREs:<EOL><INDENT>matchObj = re.compile(keyRE)<EOL>found = False<EOL>for keyName in allReportKeys:<EOL><INDENT>match = matchObj.match(keyName)<EOL>if match and match.end() == len(keyName):<EOL><INDENT>matchingReportKeys.append(keyName)<EOL>found = True<EOL><DEDENT><DEDENT>if not found:<EOL><INDENT>raise _BadKeyError(keyRE)<EOL><DEDENT><DEDENT>return matchingReportKeys<EOL>
Extract all items from the 'allKeys' list whose key matches one of the regular
expressions passed in 'reportKeys'.

Parameters:
----------------------------------------------------------------------------
reportKeyREs:     List of regular expressions
allReportKeys:    List of all keys

retval:         list of keys from allReportKeys that match the regular expressions
                  in 'reportKeyREs'
                If an invalid regular expression was included in 'reportKeys',
                  then BadKeyError() is raised