test
Does this string match? The boolean your branches have been missing
- BOOLEAN
Every workflow eventually needs to make a decision about text, and ComfyUI's stock toolbox is bad at it. "Does this filename contain a version number?" "Is this a negative prompt?" "Is this caption a known style tag?" Those are pattern questions, and this node answers them with a clean BOOLEAN: run a search, return True if anything matched, False if not. That output feeds straight into this pack's if/else, flow-select, and other control-flow nodes, which is the entire point.
The name undersells it. This isn't a debugging utility - it's the switch that turns a wall of text into a branch. Filenames, prompts, whatever string you're processing, test turns "does it look like X" into something the graph can route on. In an automation-heavy ComfyUI setup it's one of the first regex nodes you'll actually wire into a real workflow.
How it works
re.search(pattern, string) and a truthiness check: True if a match was found anywhere in the string, False otherwise. Three semantics worth being precise about:
- It's a search, not a full-match.
pattern = "\d+"returnsTruefor"image_42"because a digit appears somewhere. If you need the whole string to match, anchor it:^\d+$. - Only the first match matters - it stops after one, so this is fast even on long text.
- An empty pattern matches anything (including empty strings), which is mathematically correct
rebehavior and practically a way to make the node always returnTrue.
Inputs and output
string- the text to check.pattern- the regex.
Output is a single BOOLEAN. Wire it into the pack's control-flow nodes, a STRING-comparison gate, or anywhere a boolean is accepted.
Installing it
Part of Basic data handling by StableLlama:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Restart, or install via ComfyUI Manager (search "Basic data handling"). No dependencies, no models - the pack is pure stdlib, so it won't fight your other nodes.
Gotchas
- Search-not-match is the classic surprise: an unanchored pattern returns
Truefor containing a match. Anchor with^/$when you want an exact check. - A malformed pattern raises a hard error; a valid-but-wrong one silently returns
False. When a branch never fires, check the pattern for "matches nothing" before suspecting the node. - Case sensitivity is on by default -
"PNG"won't matchpng. Preprocess the string to lowercase, or write the case variants into the pattern, if that's what your data needs.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| string | STRING | — | |
| pattern | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BOOLEAN | BOOLEAN | — |