Nodes/ComfyUI-mnemic-nodes/✂️ String Text Extractor
ComfyUI Node

✂️ String Text Extractor

Pull whatever's sitting between a pair of brackets

By MNeMoNiCuZ·Created 3 years ago·Updated 23 days ago· 105
✂️ String Text Extractor
    • extracted_text
    • remainder_text
    • extracted_list
    input_string
    delimiters

    Hands you the content stuck between two delimiter characters - [], **, <>, whatever pair you name - instead of you writing your own string-splitting logic every time an LLM or Groq node wraps its useful output in some kind of marker.

    How it works

    It finds the first occurrence of the delimiter pair in input_string and pulls out what's inside. extracted_list goes further and grabs every occurrence in the string, not just the first, in case there's more than one bracketed chunk to find. remainder_text gives you the leftover - the original string with the extracted segment and its surrounding delimiters removed - which is handy when the bracketed part and the rest of the text both need to go somewhere different downstream.

    The inputs and outputs that matter

    • input_string - the text to search, multiline.
    • delimiters - the pair of characters marking what to extract. The tooltip's own examples: [], **, <>.

    Outputs: extracted_text (content inside the first pair), remainder_text (everything else, with the extracted content and its delimiters stripped out), and extracted_list (every match in the string, not just the first).

    How to install it

    Via ComfyUI Manager: search ComfyUI-mnemic-nodes, install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MNeMoNiCuZ/ComfyUI-mnemic-nodes
    

    Restart ComfyUI. No model downloads or extra dependencies.

    Common issues & troubleshooting

    Nothing gets extracted even though the text looks right. This node matches literal characters, not a regex pattern - delimiters needs to be exactly the pair you expect in the text. If the opening delimiter shows up without a matching closing one anywhere after it, there's nothing to extract and extracted_text comes back empty.

    Only got the first match, but the string has several. That's expected - extracted_text is specifically the first occurrence. If you need every instance, that's what extracted_list is for; check that output instead of assuming the node missed the rest.

    A real use case: you've asked a Groq or other LLM node to wrap its actual answer in a marker - "put your final caption in [brackets]" - so you can separate the useful payload from any surrounding chatter the model added. This node is the clean way to pull just that payload back out without hand-rolling string slicing.

    Choosing your delimiter pair matters. If your source text might legitimately contain the same characters elsewhere - say you're extracting from [] but the surrounding text also uses square brackets for something unrelated - you'll get whatever's between the first opening and closing pair, which may not be the segment you actually meant. Picking a delimiter pair that's unlikely to appear naturally in the rest of the text (like <> around a specific tag) avoids that ambiguity entirely.

    Category⚡ MNeMiC Nodes

    Inputs (2)

    NameTypeDefaultDescription
    input_stringSTRINGThe input text to search within.
    delimitersSTRINGThe pair of characters to use as delimiters. Example: [], **, <>

    Outputs (3)

    NameTypeDescription
    extracted_textSTRINGThe content found inside the first instance of the specified delimiters.
    remainder_textSTRINGThe rest of the text after the extracted content and its delimiters have been removed.
    extracted_listSTRINGA list of all items found between the delimiters.