判断是否包含字符🐠meeeyo.com
Does this text contain that string? Returns 1 or 0, ready to route on
- INT
CheckSubstringPresence answers one question: "does this text contain that string?" - as a hard INT 1 (yes) or 0 (no). It's the boolean-check half of the MeeeyoAI/ComfyUI_StringOps pack, the node you reach for when you want a yes/no signal to drive a switch instead of eyeballing a prompt and deciding by hand.
It's the simpler cousin of TextConditionCheck (which gates on length and character frequency). This one only asks about presence, which covers a surprising amount of graph logic: "is this a character prompt or a scene prompt?", "did this prompt come through with a LoRA keyword?", "does this filename contain the batch tag?"
The inputs
- input_text - the text to search.
- substring - what to look for. Multiple terms,
|-separated (default查找符1|查找符2, the Chinese placeholder pair). - mode - a dropdown that decides how multiple terms combine: 同时满足 (all terms must be present) or 任意满足 (any one is enough, the default).
The output
A single INT: 1 or 0. No string variant here (unlike some pack siblings that mirror INT to STRING), so plan to wire it into a numeric port - a Switch index, an if/else condition, or CompareInt for more elaborate branching.
The gotchas
Presence checks are loose, and it pays to remember exactly how loose:
- Matching is a plain substring test -
catmatchescategory,catwalk,concatenate. If you need word boundaries, this node won't give them to you; pad the term (cat,orcat) to narrow things. - The separator is
|, and the match is per-term, not a pattern. A term likea|bis two separate searches, not a regex. - "任意满足" (any) vs "同时满足" (all) - the labels are Chinese, and they do exactly what they say. With any-of mode, one hit is enough; with all-of mode, every term must be found or you get 0.
- It's case-sensitive.
Catandcatare different searches.
It's also deterministic and stateless, which makes it a good building block: a presence test feeding a Switch is a mini decision tree that doesn't reroll or surprise you.
Wiring and pairing
Use it to gate a branch: if the prompt contains "portrait", route to the portrait-oriented workflow; otherwise keep the default. Pair it with RandomLineFromText to detect which category the random pick landed in, or with BatchReplaceStrings to verify a cleanup actually removed a token before you trust the result. Any place a human would squint at text and answer "yes or no," this node answers faster and never blinks.
Installing
Same install as the rest of the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/MeeeyoAI/ComfyUI_StringOps.git
or via ComfyUI Manager searching ComfyUI_StringOps, then restart. Under "Meeeyo/String". No models, no dependencies to fetch.
A tiny node, but "can I turn a text check into a number the graph can route on" is a question every branching workflow eventually asks. This is the cheapest answer in the pack.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| input_text | STRING | 文本内容 | — |
| substring | STRING | 查找符1|查找符2 | — |
| mode | COMBO | 任意满足 | 2 options: 同时满足, 任意满足 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |