def glob_to_re(glob):
    """Translate a shell glob-like pattern to a regular expression.

    Currently there is no way to quote glob metacharacters "*" and "?".

    Parameters:
        glob (str) : A glob like pattern using "*" to match any number of chars and "?" to match a single char.

    Returns:
        str : An equivalent regular expression.
    """
    globOffset = 0
    globLen    = len(glob)
    regex      = '^'
    while globOffset < globLen:
        globChar   = glob[globOffset]
        globOffset = globOffset + 1
        if globChar == "*":
            regex = regex + '.*'
        elif globChar == "?":
            regex = regex + '.'
        elif globChar in [".","[","]","\\","^","$","+","{","}","|","(",")"]:
            regex = regex + '\\' + globChar
        else:
            regex = regex + globChar
    regex = regex + "$"
    return regex