Nodes/ComfyUI LC123 Nodes/LC Text Remove πŸ”ͺ
ComfyUI Node

LC Text Remove πŸ”ͺ

LC Text Remove β€” strip words from a prompt without shredding the spaces

By lonecatone23Β·Created 2 months agoΒ·Updated 3 days agoΒ· 18
LC Text Remove πŸ”ͺ
    • text
    β—„textβ€”β–Ί
    β—„entrycount1β–Ί
    β—„use_regexfalseβ–Ί
    β—„count0β–Ί
    β—„find_1β–Ί
    β—„find_2β–Ί
    β—„find_3β–Ί
    β—„find_4β–Ί
    β—„find_5β–Ί
    β—„find_6β–Ί
    β—„find_7β–Ί
    β—„find_8β–Ί
    β—„find_9β–Ί
    β—„find_10β–Ί
    β—„find_11β–Ί
    β—„find_12β–Ί
    β—„find_13β–Ί
    β—„find_14β–Ί
    β—„find_15β–Ί
    β—„find_16β–Ί
    β—„find_17β–Ί
    β—„find_18β–Ί
    β—„find_19β–Ί
    β—„find_20β–Ί

    LC Text Remove is a find-and-delete node for prompt strings: feed it text, tell it up to twenty substrings to delete, and it hands you the cleaned string. It's the sibling of LC Text Replace with the replacement half removed - for the surprisingly common case where you want something gone, not changed.

    Why would you want this in a graph instead of just editing the prompt? Because the text often isn't literal - it's the output of another node. A wildcard line, a joined prompt from the Prompt Builder, or a caption from a tagger all arrive as data. LC Text Remove lets you strip, say, a (low quality) tag that keeps coming back, or delete a style token from a shared prompt before it hits the CLIP encoder, without breaking the pipeline that produced it.

    How it works

    You get one text input (force-input, so it takes a wire) and a stack of find_1 through find_20 slots. Three controls shape the behavior:

    • entrycount (1–20) - how many find rows are shown and applied. Raise it to add rows; the node grows with your needs.
    • use_regex - treat each find as a regular expression instead of a literal substring. Handy for patterns like \(.*?\) to nuke all parenthesized weight tags at once. Bad regexes are silently skipped, which is forgiving but means a typo just does nothing - check your output.
    • count - max removals per find. 0 means remove all matches, which is the default.

    The removals run sequentially, in slot order, each pass operating on the result of the last. So the output is order-sensitive: if find_1 is "cat" and find_2 is "catwoman", removing "cat" first will already have eaten the "catwoman" match. Think top-to-bottom.

    The output is a single text string. Standard use: out to the CLIP Text Encode or into a Join Strings / Prompt Assembler.

    Where people get burned

    The two design details here exist because of real failure modes the author clearly hit.

    First, whitespace-only finds are ignored - this is deliberate, not a bug. If you tried to remove a trailing space by setting a find to " ", you'd otherwise glue the whole prompt into one word. So blank-ish rows are skipped entirely.

    Second, leftover double spaces are collapsed after the removals run. Remove "blue" from "a blue fox" and you get "a fox", not "a fox". It also tidies spaces around newlines, so multi-line prompt blocks stay readable.

    The trap that will bite you: a find that's a substring of other words. Remove "art" and "artist" becomes "ist". That's not the node being clever - it's plain string replacement, so think about what your find actually matches. And remember the sequential thing above; if two finds overlap, the order you list them decides the outcome.

    Install

    This ships in lonecatone23's ComfyUI_LC123_nodes pack - 89 small utility nodes, MIT licensed, and notable for having no extra pip dependencies (just torch/numpy from ComfyUI). Install it like any custom node:

    • ComfyUI Manager - search "LC123", install, restart.
    • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/lonecatone23/ComfyUI_LC123_nodes, then restart.

    Verdict

    It's a small text utility, and if you only hand-type prompts you'll rarely need it. But the moment your prompts become data - wildcards, builders, taggers - a wire-in, wire-out find/delete that never mangles whitespace is the kind of thing you reach for constantly. For literal-text jobs, LC Text Replace (its sibling) does both find and replace; grab this one when deletion is all you need.

    CategoryLC123/utils

    Inputs (24)

    NameTypeDefaultDescription
    textSTRINGSource text to transform.
    entrycountINT11–20Number of find rows to show and apply.
    use_regexBOOLEANfalseTreat find as a regular expression.
    countINT00–99999Max removals per find. 0 = remove all matches.
    find_1optSTRINGText #1 to remove (skipped if empty or only spaces).
    find_2optSTRINGText #2 to remove (skipped if empty or only spaces).
    find_3optSTRINGText #3 to remove (skipped if empty or only spaces).
    find_4optSTRINGText #4 to remove (skipped if empty or only spaces).
    find_5optSTRINGText #5 to remove (skipped if empty or only spaces).
    find_6optSTRINGText #6 to remove (skipped if empty or only spaces).
    find_7optSTRINGText #7 to remove (skipped if empty or only spaces).
    find_8optSTRINGText #8 to remove (skipped if empty or only spaces).
    find_9optSTRINGText #9 to remove (skipped if empty or only spaces).
    find_10optSTRINGText #10 to remove (skipped if empty or only spaces).
    find_11optSTRINGText #11 to remove (skipped if empty or only spaces).
    find_12optSTRINGText #12 to remove (skipped if empty or only spaces).
    find_13optSTRINGText #13 to remove (skipped if empty or only spaces).
    find_14optSTRINGText #14 to remove (skipped if empty or only spaces).
    find_15optSTRINGText #15 to remove (skipped if empty or only spaces).
    find_16optSTRINGText #16 to remove (skipped if empty or only spaces).
    find_17optSTRINGText #17 to remove (skipped if empty or only spaces).
    find_18optSTRINGText #18 to remove (skipped if empty or only spaces).
    find_19optSTRINGText #19 to remove (skipped if empty or only spaces).
    find_20optSTRINGText #20 to remove (skipped if empty or only spaces).

    Outputs (1)

    NameTypeDescription
    textSTRINGβ€”