Txt Reg
The regex node that pulls numbers, URLs, and phone parts out of anything
- STRING
You've got a blob of text and you need the numbers out of it. Order IDs, prices, phone numbers, URLs, timestamps - that is this node's entire job, and it's the pack's headline act. TxtReg is the regex extractor in the wwdm-aicd pack, and if you install the pack for one thing, this is it.
The node wraps Python's re module with a friendlier face. You feed it a text, give it a pattern, and it has five modes. extract_all grabs every match as a list. extract_group pulls one captured group out of each match (handy for "give me just the domain from every email"). replace does regex substitution - the classic trick is masking phone numbers by keeping the first and last digits and replacing the middle. split splits the text on the pattern. match_first returns only the first hit. Since the output is a STRING list, it drops straight into the pack's other nodes - TxtRegSelect, ListOps, JsonBuilder - which is exactly the pipeline the README pitches: extract → filter → structure.
The inputs you'll actually touch: text, pattern, and mode. The default pattern is \d+, so out of the box it just finds all numbers. If you're extracting from a specific pattern with capture groups, that's where group_index comes in - for @([\w.]+) against a string full of emails, group index 0 gives you the domains. replacement only matters in replace mode. Then there are the fiddly but useful ones: flags is a string of letters (i for ignore case, m multi-line, s dot-matches-newline, x verbose, a ASCII), max_matches caps how many results you get back, dedupe collapses duplicates, and output_mode toggles between a list and a single joined string with join_separator. Want one clean comma-separated line instead of a list? Set output_mode to join.
Install is about as easy as it gets, because this pack is pure Python with zero heavy dependencies:
cd ComfyUI/custom_nodes
git clone https://github.com/wwsmiao/comfyui-wwdm-aicd.git
Restart ComfyUI and it shows up under the wwdm-aicd menu category (or search "comfyui-wwdm-aicd" in ComfyUI Manager). One trap: the README tells you to pip install -r requirements.txt, but there is no requirements.txt in the repo - the node only uses the standard library and things ComfyUI already bundles, so skip that step. The README is in Chinese, and so are the code docstrings, which is worth knowing if you go spelunking in the source.
Where people get burned: regex in the ComfyUI widget. The default pattern shows as \d+, but if you're pasting from elsewhere, remember the widget is a plain string - a pattern written for JSON (with \\d) will behave differently. And regex can silently do nothing: if the pattern fails to compile, the node just returns an empty list instead of yelling at you, so a "why is my output empty" moment usually means a bad pattern, not a broken install. That's the one genuinely frustrating design choice here; a parse error would be friendlier than an empty result.
The README's data-extraction pipeline is the honest best use: TxtReg pulls structured bits out of raw text, TxtRegSelect picks the ones you want, JsonBuilder turns them into JSON, and JsonParser unwraps whatever an LLM returned. It's the front door to all of that.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| pattern | STRING | \d+ | — |
| mode | COMBO | extract_all | 5 options: extract_all, extract_group, replace, split, match_first |
| group_index | INT | 0 | — |
| replacement | STRING | — | |
| output_mode | COMBO | list | 2 options: list, join |
| join_separator | STRING | , | — |
| flagsopt | STRING | — | |
| max_matchesopt | INT | 0 | — |
| dedupeopt | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |