Nodes/ComfyUI-PromptWrapper/Multi Replace Prompt
ComfyUI Node

Multi Replace Prompt

Find-and-replace, six rules, regex under the hood

By clouddreamfly·Created 2 years ago·Updated 9 months ago· 4
Multi Replace Prompt
    • text
    ◄prompt—►
    ◄pattern_A►
    ◄replace_A►
    ◄pattern_B►
    ◄replace_B►
    ◄pattern_C►
    ◄replace_C►
    ◄pattern_D►
    ◄replace_D►
    ◄pattern_E►
    ◄replace_E►
    ◄pattern_F►
    ◄replace_F►
    ◄match_fullfalse►
    ◄match_casefalse►
    ◄match_regexfalse►

    Multi Replace Prompt is Replace Prompt with the budget doubled: six find-and-replace rules (pattern_A/replace_A up to pattern_F/replace_F) applied in sequence to an incoming prompt. If you're normalizing downloaded workflows - stripping embedded quality tags, swapping model-specific vocab, cleaning up a dozen synonyms into your standard phrasing - one node with six rules beats a chain of three three-rule nodes every time.

    How it works

    Identical helper as its smaller sibling: for each non-empty pattern, it runs re.sub over the accumulated text, so rules cascade - rule B sees the output of rule A, rule C sees that result, and so on. The match toggles (match_full, match_case, match_regex) are the same as Replace Prompt's: matching is case-insensitive regex by default, and the toggles only shuffle flags rather than switching regex on and off. Treat every pattern as a regex and you won't be surprised.

    Inputs that matter

    • prompt - force-wired input text.
    • pattern_A through pattern_F + the matching replace_X - six ordered rules. Empty patterns are skipped, so you can use two rules or all six.
    • match_case, match_regex, match_full - flag toggles with the same caveats as Replace Prompt (match_full doesn't mean whole-string matching).

    One text output with all replacements applied.

    Install

    ComfyUI Manager → Custom Nodes Manager → search ComfyUI-PromptWrapper → Install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/clouddreamfly/ComfyUI-PromptWrapper
    

    No dependencies, no models.

    Where people get burned

    Regex escaping, again, is the entire failure surface. Replacing the literal (best quality:1.2) needs \(best quality:1\.2\) because the metacharacters are live. And because rules cascade, order matters: if rule A turns "girl" into "woman" and rule B replaces "woman", the order in which you list them changes the result - that's a feature, but it means a confusing bug if you forget A runs first. One more thing worth knowing: the six rules share a single prompt input and a single output, so unlike some string tools there's no per-rule branching - think of it as a pipeline, not six independent replaces.

    CategoryPromptWrapper

    Inputs (16)

    NameTypeDefaultDescription
    promptSTRING—
    pattern_ASTRING—
    replace_ASTRING—
    pattern_BSTRING—
    replace_BSTRING—
    pattern_CSTRING—
    replace_CSTRING—
    pattern_DSTRING—
    replace_DSTRING—
    pattern_ESTRING—
    replace_ESTRING—
    pattern_FSTRING—
    replace_FSTRING—
    match_fullBOOLEANfalse—
    match_caseSTRINGfalse—
    match_regexSTRINGfalse—

    Outputs (1)

    NameTypeDescription
    textSTRING—