Nodes/ComfyUI_StringOps/段落提取或移除字符行🐠meeeyo.com
ComfyUI Node

段落提取或移除字符行🐠meeeyo.com

Keep or drop lines by keyword — grep, but inside your workflow graph

By MeeeyoAI·Created 2 years ago·Updated about a year ago· 209
段落提取或移除字符行🐠meeeyo.com
    • STRING
    input_text
    substrings查找符1|查找符2
    action保留

    FilterLinesBySubstrings is the workflow-graph equivalent of grep with -v: give it a block of text, tell it which substrings matter, and it either keeps the lines that contain any of them or removes those lines. One STRING out the other side. It's a line-level filter, so it's the node you reach for when a prompt block or tag list has grown unruly and you want to trim it programmatically instead of by hand.

    Typical jobs: from a long prompt bank, keep only the lines that mention a specific LoRA or style tag; strip "worst quality, bad anatomy" style negative-tag lines out of a shared prompt block; or pre-filter a big text list before handing it to a random-line picker so you only ever draw from the relevant subset.

    The three inputs

    • input_text - the multiline text to filter. Line-based, so newlines are the boundaries.
    • substrings - the matchers, separated by |. Default 查找符1|查找符2 is just the Chinese for "search char 1|search char 2"; replace it with your own terms like cat|dog.
    • action - a dropdown with two choices: 保留 (keep) or 移除 (remove). Keep means "only lines that contain at least one of the substrings survive"; remove means "only lines that contain none of them survive."

    How it actually works

    The node splits your text into lines, checks each line for a substring match (it's a plain in check - no regex, no word boundaries), and re-joins the survivors with newlines. Two behaviors worth knowing:

    • Matching is any-of: with cat|dog, a line containing either word passes the keep test. There's no "must contain all" mode here.
    • The output strips blank lines. If a filtered block has empty lines left over, they're gone on the way out - usually a blessing, occasionally surprising if you were counting on the layout.

    Where people get burned: substring matching is loose. cat matches category, catwalk, cataclysm. If your keyword is short, expect false positives and pad the term (e.g. cat, or a fuller phrase) to narrow it. And remember the two action labels are Chinese - 保留/移除 - so if you're staring at a node that seems to be doing the opposite of what you set, you may have the pair backwards.

    It pairs well with the rest of the pack: filter a bank down to relevant lines, then feed the result to RandomLineFromText for a random pick, or to ExtractSpecificLines if you know the slot you want.

    Installing

    Part of MeeeyoAI/ComfyUI_StringOps - install via Manager (search ComfyUI_StringOps) or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MeeeyoAI/ComfyUI_StringOps.git
    

    Restart ComfyUI, find it under "Meeeyo/String". No models, no heavy deps. Like the pack's other string nodes it marks itself always-changed, so it re-runs every queue execution - irrelevant for a deterministic filter, harmless regardless.

    It's a niche tool, but if you've ever hand-deleted lines out of a prompt list for the fiftieth time, this is the node that makes that a one-time setup.

    CategoryMeeeyo/String

    Inputs (3)

    NameTypeDefaultDescription
    input_textSTRING
    substringsSTRING查找符1|查找符2
    actionCOMBO保留2 options: 保留, 移除

    Outputs (1)

    NameTypeDescription
    STRINGSTRING