import re


def input_require_match_reqex(regex, raw_input):
    """
    Utility function that requires a given input to match a given regular expression.
    In case the expression is not met, ask the user to repeat the input in a valid format.
    :param regex: the regular expression the input should be checked with
    :type regex: str
    :param raw_input: the initial input to check
    :type raw_input: str
    :return: the user input matching the given expression
    :rtype: str
    """
    while not re.match("^[_a-zA-Z][_a-zA-Z0-9\-]*$", raw_input):
        raw_input = input("Please input a valid string as name (should match \"" + regex + "\"):\n")
    return raw_input