import re


def extract_re_group(pattern):
    """
    Extract the first captured group using the given pattern.
    """
    def callable_(key, data, errors, context):
        value = data.get(key) or ''
        match = re.match(pattern, value)
        if not match:
            return
        try:
            data[key] = match.group(1)
        except IndexError:
            return

    return callable_