Nodes/ComfyUI_Eclipse/Replace String Advanced
ComfyUI Node

Replace String Advanced

Turn Messy LLM Prompt Dump Into a Clean Tag List

By r-vageΒ·Created 10 months agoΒ·Updated a day agoΒ· 31
Replace String Advanced
    • string
    β—„stringβ–Ί
    β—„regexβ–Ί
    β—„replace_withβ–Ί
    β—„featuresβ–Ί
    β—„age25β–Ί
    β—„nsfw_handlingnoneβ–Ί

    What it is

    Replace String Advanced is what you reach for when a prompt needs real cleanup, not a find-and-replace. Where the plain Replace String does one regex substitution, this node layers on pattern-based content removal: strip the instruction boilerplate, drop the image-style and shot-style tags, yank the subject or background descriptions, normalize ages, remove watermarks - all from one set of feature toggles. Then, if you want it, NSFW handling on top.

    The scenario this exists for will be familiar if you've ever piped an LLM or a captioning model into a prompt encoder. The model returns a paragraph: "A cinematic still of a young woman in a red dress, shot on 35mm, moody lighting, remove watermark, watermark, studio..." - and half of it is meta-instructions your diffusion model will happily try to render as content. This node strips the instructions and leaves the actual prompt.

    How it works

    Two engines. First, the familiar one: an optional regex pattern with a replacement, applied case-insensitively. Second, the feature system - a combo-chip widget (the pack renders it as selectable chips) where each enabled feature routes the text through a pattern-based processor. The feature list: instructions, list_first, list_to_string, image_style, shot_style, subject, background, mood, lighting, age, watermark, cleanup. Each one targets a category of content the pack's SmartTextProcessor patterns know how to find and remove.

    Two toggles are worth singling out. age doesn't just remove age references - with the feature enabled it rewrites them toward the target age you set (default 25, range 18–99), which is genuinely useful when you're generating a character consistently and the prompt keeps drifting between "teen" and "elderly". And nsfw_handling is self-explanatory: none keeps content as-is, soften rewrites it to preserve structure while removing explicit terms ("nude woman" β†’ "woman"), and remove deletes NSFW content outright.

    The inputs that matter

    • string - the input to process.
    • regex / replace_with - optional classic regex substitution, applied before the feature pass.
    • features - the combo-chip list of cleanup operations (instructions, image_style, shot_style, subject, background, mood, lighting, age, watermark, cleanup, list_first, list_to_string).
    • age - target age when the age feature is enabled.
    • nsfw_handling - none / soften / remove.

    Output:

    • string - the processed text.

    When you'd use it

    Feeding LLM/VLM output into a prompt encoder, cleaning captions for training data, normalizing a mixed bag of prompt sources into one consistent format, and any workflow where "the model keeps rendering the word 'watermark'" is a problem you've actually had. It's the cleanup stage between "whatever produced this text" and "whatever consumes it as a prompt".

    Installing it

    It's part of ComfyUI_Eclipse:

    cd ComfyUI/custom_nodes
    git clone https://github.com/r-vage/ComfyUI_Eclipse
    pip install -r ComfyUI_Eclipse/requirements.txt
    

    then restart, or install via Manager (search "Eclipse"). It relies on the pack's pattern files (in patterns/), which are extracted from .defaults/ on first launch - if the features stop matching, check those files are present. And as with everything in this pack (formerly RvTools_v2), old pre-v4.0.0 workflows may need the bundled migration tool.

    Common issues

    Two things bite. The feature processors are pattern-based, and patterns are opinions - they catch the common shapes of instruction text, but an unusual phrasing will sail through, so spot-check output instead of trusting it blindly. And the NSFW softening is keyword-driven, which is fine for tags but will miss euphemistic phrasing. Neither is a bug; they're the limits of text patterns, and knowing them saves you from expecting magic.

    CategoryπŸŒ’ Eclipse/ Text

    Inputs (6)

    NameTypeDefaultDescription
    stringSTRINGInput string to process.
    regexSTRINGRegular expression pattern to match.
    replace_withSTRINGReplacement string for matches.
    featuresSTRINGComma-separated feature list. JS combo-chip replaces this widget.
    ageINT2518–99Target age to use when age feature is enabled.
    nsfw_handlingCOMBOnoneHow to handle NSFW content: 'none' (keep as-is), 'soften' ('nude woman' β†’ 'woman', preserves structure), 'remove' (delete NSFW content entirely).

    Outputs (1)

    NameTypeDescription
    stringSTRINGβ€”