        return qmark_regex.join(fragment_to_regex(ff) for ff in f.split("?"))
    return re.escape(f)

twostars_regex = "(?:.*/)*"
onestar_regex = "[^/]*"
qmark_regex = "[^/]"

def fragments_to_regex(fragments):
    regex_str_pieces = []
    for fragment in fragments:
        if fragment == "":
            regex_str_pieces.append("/")
        elif fragment == "**":
            regex_str_pieces.append(twostars_regex)
        else: