Regex Text Chopper /noEmbryo
Slice a prompt into parts without a dozen string nodes
- Part 1
- Part 2
- Part 3
- Part 4
- All parts
Regex is one of those things ComfyUI makes you work for. Want to pull a style tag out of a long prompt, split a metadata dump, or fish a seed out of a blob of text? Normally that's a math node, a few string operations, and a prayer. This little node from the noEmbryo pack compresses all of that into one box: give it text and a pattern, and it hands you back the matches on separate outputs.
It's a niche tool - you won't use it in every workflow, but the day you need it, you need it badly and nothing stock does it. That's the whole pitch.
How it works
The mechanism is plain Python re.findall(pattern, text, re.MULTILINE) - no custom parsing, no magic. It runs the pattern against your text, collects every match, and routes the first four into the Part 1 through Part 4 outputs. All parts is every match joined together with blank lines, which is handy when you want the whole extraction as one string but don't know how many matches you'll get.
Inputs and outputs
- text - the string to parse. It's
forceInput, so you can wire it straight from a CLIP Text Encode, a text box, or another node's output instead of typing into it. - regex - your pattern, entered as plain text. Python regex syntax applies.
Outputs are Part 1, Part 2, Part 3, Part 4, and All parts - all STRING type, ready to feed into anything that accepts text.
The traps, and they're real ones
- It only returns the first four matches. Fifth match onward still shows up inside All parts, but Part 1–4 are capped. If you're extracting more than four things, wire the All parts output instead and split downstream.
- Don't use capturing groups unless you mean it.
re.findallreturns tuples instead of plain strings when your pattern has()groups - so Part 1 might come out as('a', 'b')rather thana. Use non-capturing groups(?:...)if you need grouping but want plain string matches. - A malformed pattern will error the node, not degrade. The code tries to be nice about this - there's a validity check that's supposed to catch bad patterns and fall back to emptying the parts. But the check compiles
re.escape(your_pattern), which basically always succeeds because escaping makes any input valid. So that fallback is effectively dead code, and a genuinely broken pattern (say, an unmatched() throws a Pythonre.errorand fails your whole queue. Validate your regex in a tester before you paste it in. - Zero matches are the real silent failure: four empty strings, and All parts is empty too. There's no visual signal, so if you get empties, first assume zero matches, then check the pattern syntax.
Install
Same as the rest of the pack: ComfyUI Manager → search "noEmbryo", or:
cd ComfyUI/custom_nodes
git clone https://github.com/noembryo/ComfyUI-noEmbryo.git
then restart. No dependencies, no models - the node ships in the pack's single nodes.py file and uses nothing but Python's built-in re module.
Honestly? Most people reach for this once, get their parse working, and never look at it again. But the node sits in your menu forever, and the next time a prompt-generation node hands you a messy string you need to dissect, you'll be glad it's there.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | The text that we'll parse | |
| regex | STRING | The RegEx pattern |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| Part 1 | STRING | — |
| Part 2 | STRING | — |
| Part 3 | STRING | — |
| Part 4 | STRING | — |
| All parts | STRING | — |