Regex Search and Match
Pull matches out of text instead of replacing them
- matches
Sometimes you don't want to change your text, you want to pull something out of it - every hashtag, every number, every LoRA tag in a prompt string - so you can do something else with just those pieces. That's SAIStringRegexSearchMatch, the extraction sibling of this pack's search-and-replace node.
What it does
Two multiline STRING inputs: text_input is the text you're scanning, regex_pattern is what you're looking for. The output, matches, is a LIST - every match the pattern found in the text, collected together, rather than a single yes/no or a single string. If your pattern doesn't match anything, expect an empty list back rather than an error.
Like this pack's replace node, the pattern is real regex - Python's flavor, since that's what the node runs on under the hood - not a glob or a simple substring search. . matches any character, character classes and quantifiers behave the way they do in any standard regex engine.
Where it's useful
Think extraction, not transformation: pulling every <lora:name:weight> tag out of a prompt string so you can process them individually, grabbing every number out of a caption, finding all instances of a specific token pattern before deciding what to do with them. Because the output is a LIST rather than a single string, it naturally feeds into whatever part of your graph is set up to iterate - this pack's own primitive converter (SAIPrimitiveConverter) can help pull individual elements back out by index if you need one specific match rather than the whole set.
Installing it
ComfyUI Manager: search SaltAI-Open-Resources. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/get-salt-AI/SaltAI
Restart ComfyUI. No extra dependencies - regex is part of Python's standard library.
Common issues
An empty matches list almost always means the pattern isn't matching what you think it is - the usual regex debugging move applies: simplify the pattern down to something you're certain should match, confirm that works, then build the complexity back up piece by piece rather than staring at one long pattern trying to spot the bug. If you meant to capture part of each match (say, just the number inside a larger tag) rather than the whole match, make sure your pattern actually uses a capture group - without parentheses around the part you want, you'll get the entire matched text back, not the sub-piece. And remember this node returns every match in the text, not just the first one - if you only expected one match and got several, check whether your pattern is broader than intended and accidentally catching things elsewhere in the string.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| text_input | STRING | — | |
| regex_pattern | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| matches | LIST | — |