段落提取或移除字符行🐠meeeyo.com
Keep or drop lines by keyword — grep, but inside your workflow graph
- STRING
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|查找符2is just the Chinese for "search char 1|search char 2"; replace it with your own terms likecat|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.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| input_text | STRING | — | |
| substrings | STRING | 查找符1|查找符2 | — |
| action | COMBO | 保留 | 2 options: 保留, 移除 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |