search groups (LIST)
Capture groups as one LIST you can index later
- LIST
Half the regex family in this pack comes in two flavors - "data list" and "LIST" - and this is the LIST one: run a search, collect the capture groups, and hand them back as a single Python list variable rather than fanning them out into individually processed items. Same regex, same matches; the difference is entirely about how you want to consume the result.
Reach for this when you want the collection intact: hold all the groups, index into them with a LIST get item node, count them, or convert to a SET for dedup. Reach for "search groups (data list)" when each group should flow into its own per-item slot downstream. If you only need one value out of a structured string, the RegexGroupDict node is usually the better tool - labels beat indices every time. But when your pattern's groups have a fixed, well-known order, a positional LIST is perfectly readable and this is the node.
How it works
One re.search(pattern, string), then list(match.groups()). The semantics that keep tripping people:
groups()returns only the parenthesized captures, in order, excluding the full match. Pattern(\d+)x(\d+)on"1920x1080"→["1920", "1080"].- Only the first match counts; this is a search, not a scan-everywhere.
- No match → empty LIST, no error. A length check downstream is how you test for "did it match."
- Non-participating optional groups come through as
None, which then needs handling before any string-consuming node.
Inputs and output
string- text to search.pattern- regex with(...)groups.
Output is one LIST of capture-group strings, in pattern order. Index it with a list accessor, or hand the whole thing to a SET/LIST node.
Installing it
Ships in 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"). The pack declares no dependencies and downloads no models - pure stdlib, so nothing at install time to fight your other nodes.
Gotchas
- Position-based, so it's brittle to pattern edits: changing group order silently reorders your data. If the string format is out of your control and stable, fine; if not, the named-group dict node is the safer read.
Noneentries from non-participating groups are real and will surface as confusing errors two nodes down the line. Filter empties early.- A malformed regex fails with
re.errorat this node; a valid-but-wrong one returns an empty list. Know which failure mode you're looking at when results vanish.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| string | STRING | — | |
| pattern | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LIST | LIST | — |