@staticmethod
def as_regex(glob):
    """
        Get the regex representation of the given glob pattern.

        :param glob: The glob pattern.
        :type glob: str
        :return: Regex equivalent of the given glob pattern.
        :rtype: typing.Pattern[str]
        """
    pattern = '^'
    i = 0
    length = len(glob)
    while i < length:
        c = glob[i]
        if c == '\\':
            i += 1
            if i == length:
                break
            c += glob[i]
            if c == '\\\\':
                c = '/'
        elif c == '.':
            c = '\\.'
        elif c == '?':
            c = '[^/]'
        elif c == '*':
            if i < length - 1 and glob[i + 1] == '*':
                i += 1
                c = '.*'
            else:
                c = '[^/]*'
        pattern += c
        i += 1
    pattern += '$'
    return pattern
