Nodes/Basic data handling/find all (data list)
ComfyUI Node

find all (data list)

Regex findall, as a data list ComfyUI can actually fan out

By StableLlama·Created about a year ago·Updated about 18 hours ago· 48
find all (data list)
    • STRING
    string
    pattern

    Regex nodes are the secret weapon of anyone who's ever been handed a prompt file, a JSON dump, or a folder of captions and needed to turn it into structured data inside ComfyUI. This one is Python's re.findall() with the crucial twist: it returns a data list, not a plain LIST. In this pack's own vocabulary (and it's a vocabulary worth learning), a data list is ComfyUI's native list type, where each element gets processed individually by downstream nodes - so you can pipe every match straight into a batch of images, prompts, or filenames instead of being stuck with one Python list variable.

    That's the whole reason to pick the "data list" variant over the "(LIST)" one. The pattern and mechanics are identical; the output type decides how the graph treats the results. If your next node expects per-item processing - a STRING slot that runs once per match - you want the data list flavor.

    How it works

    Under the hood it's a single call to re.findall(pattern, string), returning every non-overlapping match in order. "Non-overlapping" is the gotcha that catches people: findall on "aaa" with pattern a+ gives you ["aaa"], not ["aaa", "a", "a"]. For a quick mental model, it's the "give me everything that matched" sibling of the pack's test (did anything match at all?) and search (give me the first match).

    The class sets OUTPUT_IS_LIST = (True,), which is the flag that tells ComfyUI "this output is a list, process each item individually." That's the mechanism behind the whole data-list story.

    Inputs and output

    • string - the text to search.
    • pattern - the regex. Standard Python re syntax, so named groups, character classes, and lookarounds all work.

    The output is a data list of STRINGs - every match, in order. No match at all just means an empty list, no error.

    A typical pairing: pull a folder of caption files, findall for "(\d+)" to grab every number, and feed the results into a batch loader or a loop. The node lives in the Basic data handling pack by StableLlama, whose regex family covers findall, search, split, substitute, test, and named-group extraction - this is one of the two you'll actually remember exists.

    Installing it

    cd ComfyUI/custom_nodes
    git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
    

    Restart, or use ComfyUI Manager and search "Basic data handling". The pack has zero dependencies and downloads nothing, which in a custom-node ecosystem where installs routinely fight each other is the whole appeal - it's stdlib-only.

    Gotchas

    • Regexes are greedy by default. .* will swallow far more than you intended until you add a ? or anchor. Test the pattern in a scratch text node before wiring it into a batch pipeline.
    • Non-overlapping matches only, as above - this is findall semantics, not "every possible match."
    • A bad regex (unclosed group, stray *) raises a re.error, and since these nodes wrap Python directly, that's the failure mode you'll see: a workflow error on that node, not a graceful empty result. A wrong-but-valid regex, by contrast, just matches nothing.
    CategoryBasic/STRING/regex

    Inputs (2)

    NameTypeDefaultDescription
    stringSTRING
    patternSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING