def parse_matches_regex(regex, value, error_message='Unmatched value [{0}]'):
    """Raises ValueError(error_message.format(value)) if value does not match
    regex.
    """
    res = regex.match(value)
    if not res:
        raise ValueError(error_message.format(value))
    else:
        return value