def METHOD_NAME(cls, string):
    # tar --transform has reverse behavior for "{}()+?|" than Python regexes (characters
    # must be escaped to invoke their special behavior, unescaped ones are handled literally)
    found_escape = False
    output = ""
    for c in string:
        if c == "\\":
            if found_escape:
                output += "\\\\"
                found_escape = False
            else:
                found_escape = True
        elif found_escape:
            if c not in "{}()+?|":
                output += "\\"
            output += c
            found_escape = False
        elif c in "{}()+?|":
            output += "\\" + c
        else:
            output += c
    return output