def esc_regex(string: str) -> str:
    """Escape non-literal regex characters in a string.

    :param string: the string to escape characters from
    :return: the string with escaped characters
    """
    return (
        string.replace("[", "\\[")
        .replace("]", "\\]")
        .replace("\\", "\\\\")
        .replace("^", "\\^")
        .replace("$", "\\$")
        .replace(".", "\\.")
        .replace("|", "\\|")
        .replace("?", "\\?")
        .replace("*", "\\*")
        .replace("+", "\\+")
        .replace("(", "\\(")
        .replace(")", "\\)")
    )