判断返回内容🐠meeeyo.com
Pick one of two strings based on a substring check
- STRING
ConditionalTextOutput is a ternary for text: it looks inside one string, and depending on whether a search term is found, returns one of two strings you provide. If/else for prompt text, in a single node - no switch nodes, no separate boolean plumbing.
It's part of the MeeeyoAI/ComfyUI_StringOps pack, and it fills the gap between the pack's pure tests (which return 1/0) and its pure transforms (which don't decide anything). This one makes the choice and hands you the finished string.
The four inputs
- original_content - the multiline text that gets searched.
- check_text - the term to look for inside it.
- text_if_exists - returned when the term is found (default
存在返回内容, "the return content when it exists"). - text_if_not_exists - returned when it isn't found (default
不存在返回内容, "the return content when it doesn't exist").
Output: a single STRING - one of the two branches, chosen at runtime. Wire it straight into a CLIP Text Encode or another text node.
The mechanics
It's a plain substring test: check_text in original_content. If the term is present anywhere - inside a word, in the middle of a sentence, doesn't matter - you get text_if_exists. Otherwise text_if_not_exists. No regex, no word boundaries, case-sensitive. That's the same looseness as CheckSubstringPresence in this pack, so short terms need padding (portrait, instead of portrait) if you want to avoid matching portraits.
One deliberate edge case: if check_text is empty, the node returns an empty string regardless - a guard, not a bug, and it means "I have no test to run" comes back as a blank rather than a surprise branch.
When to reach for it
This is the node for "swap the prompt depending on context." Examples: if a style token made it into the prompt, return the enhanced positive prompt; otherwise return the basic one. If a batch tag is present in the filename, emit a filename suffix; otherwise emit nothing. If a check upstream produced a flag word, translate it into a full prompt phrase on the fly.
It pairs well with the pack's tests: use CheckSubstringPresence or TextConditionCheck as the gate when you need the boolean itself, or skip straight to ConditionalTextOutput when you only ever wanted the resulting text anyway. Both approaches work; this one is fewer nodes.
Installing
Standard pack install:
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 worry about.
It's a small node with a clean mental model: one test, two outputs, choose one. The only thing to keep in mind is that the test is a loose substring match - everything else is as predictable as a light switch.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| original_content | STRING | — | |
| check_text | STRING | 查找字符 | — |
| text_if_exists | STRING | 存在返回内容 | — |
| text_if_not_exists | STRING | 不存在返回内容 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |