import re


def parse_arbitrary(trace_line, regex):
    """Apply the regex to the string, returning the matching groups (if any).

    trace_line and regex are both strings.
    """
    parser = re.compile(regex)
    result = parser.match(trace_line)
    if result:
        return result.groups()