def match1(text, *patterns):
if len(patterns) == <NUM_LIT:1>:<EOL><INDENT>pattern = patterns[<NUM_LIT:0>]<EOL>match = re.search(pattern, text)<EOL>if match:<EOL><INDENT>return match.group(<NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>else:<EOL><INDENT>ret = []<EOL>for pattern in patterns:<EOL><INDENT>match = re.search(pattern, text)<EOL>if match:<EOL><INDENT>ret.append(match.group(<NUM_LIT:1>))<EOL><DEDENT><DEDENT>return ret<EOL><DEDENT>
Scans through a string for substrings matched some patterns (first-subgroups only).

    Args:
        text: A string to be scanned.
        patterns: Arbitrary number of regex patterns.

    Returns:
        When only one pattern is given, returns a string (None if no match found).
        When more than one pattern are given, returns a list of strings ([] if no match found).