import re


def find_first_instance(regex, infile):
    """Find the first line in the given file that matches the given regular
    expression and return the string concatenation of the result strings
    corresponding to the matching groups."""
    with open(infile, 'r') as f:
        pattern = re.compile(regex)
        for line in f:
            m = pattern.match(line)
            if m is not None:
                if pattern.groups > 0:
                    res = ""
                    for g in m.groups():
                        res = res + g
                    return res
                else:
                    return m.group(0)
    return None