def get_first_match(regex, directory):
    """
    Checks if `directory` matches `regex` and returns the first match converted
    to an integer. If it does not match -1 is returned.

    Arguments:
    - `regex`: Regular expression to be tested against
    - `directory`: name of the directory under test
    """

    result = regex.search(directory)
    if result is None:
        return -1
    else:
        return int(result.group(1))