import re


def match_first(string, prefix_infos, key):
    """Match string against each regex. Return first match, or None"""

    for prefix_info in prefix_infos:
        regex = prefix_info.get(key)
        if regex:
            match = re.match(regex, string)
            if match:
                prefix_info["match"] = match.groupdict()
                return prefix_info

    return None