Regex Find
Slice text out of prompts with a regex
- found_match
Every once in a while you need to find something inside a string instead of generate something. Regex Find (class RegexFindNode) takes a chunk of text and a regular expression, and returns the first substring that matches. That's the whole node - but the whole node is enough to do surprising amounts of work.
Say you have a prompt or a filename and you want just one piece of it: the subject, the style tag, the number buried in a filename, the quality keyword. Regex is the Swiss Army knife for that, and this node is how you get it into a ComfyUI graph. It's in the pack's "String Tools" category for good reason - it exists to parse and extract, not to write.
How it works
Two inputs:
input_string- the text to search (multiline, so paste freely)regex_pattern- the pattern to match. The default is(?<=in\s)(.*?)(?=,)
That default is worth understanding because it's a good template. It reads as: "after the word 'in' and a space, take everything up to the next comma." So a cat in a hat, wearing boots returns a hat. See the pattern? It's an extractor for that specific grammar - grab the thing sitting between two markers. If you want something else, you edit the lookbehind (?<=in\s) and the lookahead (?=,) to bracket your target.
The output is found_match (STRING) - the first match, or an empty string if nothing matched.
Where it fits
The realistic uses are prompt cleanup and data wrangling. Pulling the style token out of a long prompt so you can reuse it elsewhere. Extracting a number from a filename before it goes into a batch. Stripping a value out of a metadata string without hand-editing. It's a utility node - you add it when you need it, and you usually know you need it because you're staring at a string you wish you could cut apart.
Installing it
This node ships in ComfyUI-CoCoTools, which is deprecated; the README redirects to ComfyUI-CoCoTools_IO and the original repo URL has 404ed on GitHub since at least August 2026. Install via ComfyUI Manager (search ComfyUI-CoCoTools) if it resolves, or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Conor-Collins/coco_tools
Install the pack requirements (Windows portable, from python_embeded/):
python.exe -m pip install -r ./ComfyUI/custom_nodes/ComfyUI-CoCoTools/requirements.txt
Restart ComfyUI to load the nodes.
Gotchas
- It returns the first match only. If your string has multiple matches and you want them all, this node won't do it - you'd be looking at a different tool.
- A no-match returns an empty string, and that's easy to confuse with a successful empty match. If extraction looks broken, test the pattern on your exact string first.
- The default pattern uses lookbehind (
(?<=) and lookahead ((?=)) syntax, which trips up people new to regex. If you're not comfortable with it, test on a site like regex101 before wiring it in - it'll save you a lot of empty strings. - Backslashes in patterns can get eaten by string handling, so check your pattern if it stops working after you edit it.
- It's abandoned software. For a one-off extraction this is fine; for a core pipeline, a maintained string-utility pack is the safer bet.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| input_string | STRING | — | |
| regex_pattern | STRING | (?<=in\s)(.*?)(?=,) | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| found_match | STRING | — |