import re


def _check_token(token, names):
    """ Checks if a token exists in names list.
    As some versions of regex module only support groups of 100, this method
    splits the names in sub-groups in order to check the token. Best case
    scenario, the token will be found in the first 100 elements. In the worst
    case, it will go through all the list as usual. """

    max_regex = 99
    grouped_names = [names[i: i + max_regex] for i in range(0, len(names), max_regex)]
    for sub_names in grouped_names:
        regexes = "(" + ")|(".join(sub_names) + ")"
        if re.match(regexes, token) is not None:
            return True
    return False