Nodes/comfyui-adaptiveprompts/⛓️‍πŸ’₯ String Split ⛓️‍πŸ’₯
ComfyUI Node

⛓️‍πŸ’₯ String Split ⛓️‍πŸ’₯

Cut a string into three parts by delimiter index

By AlectricitiΒ·Created 12 months agoΒ·Updated 23 days agoΒ· 87
⛓️‍πŸ’₯ String Split ⛓️‍πŸ’₯
    • String A
    • String B
    • String C
    β—„textβ–Ί
    β—„start0β–Ί
    β—„end1β–Ί
    β—„delimiter,β–Ί

    Where PromptSplitter trims a prompt down by randomly removing sections, StringSplit does the deterministic opposite: it cuts a string into exactly three named pieces using fixed delimiter-occurrence indices, so you always get the same slice back for the same input. Reach for this when you know exactly which chunk of a structured string you want isolated - say, always grabbing whatever sits between the second and fourth comma of a consistently-formatted prompt.

    How it works

    It counts occurrences of delimiter (default ,) inside text, then splits at the start-th and end-th occurrence. Everything before the start-th delimiter becomes String A, everything between the start-th and end-th delimiter becomes String B, and everything after the end-th delimiter becomes String C. With the schema's defaults - start at 0, end at 1 - that grabs the content around the very first delimiter in the string, which suggests 0-indexed counting; test it on a short, known input before trusting it on a long real prompt so you know exactly which occurrence you're landing on.

    The inputs and outputs that matter

    • text - the string to split.
    • start - index of the first delimiter occurrence to split from.
    • end - index of the second delimiter occurrence to split until.
    • delimiter - what to split on (default ,).
    • Outputs: String A, String B, String C.

    How to install it

    Ships with the rest of the pack - search comfyui-adaptiveprompts in ComfyUI Manager, or install manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Alectriciti/comfyui-adaptiveprompts
    

    Restart ComfyUI. No models, no extra dependencies.

    Common issues & troubleshooting

    The middle section isn't what you expected. Indices here count delimiter occurrences, not characters or words - the classic off-by-one mistake is assuming start/end map to something else. Run a short test string like a,b,c,d,e through with a few different start/end combinations first so you can see exactly which comma each index lands on before wiring it into a real workflow.

    The pack's own README table describes this node oddly. Worth flagging honestly: the README's quick-reference table lists "String Split" and "Tag Counter" with the identical description text ("Directly splits a prompt into 3 parts to isolate a middle section using start and end") - that's a copy-paste slip in the README's table, not a hint that the two nodes behave identically. Go by the tooltips and behavior described here (which come straight from the node's own schema) rather than that table row if anything seems to conflict.

    No delimiter found at all. If delimiter doesn't appear at least end times in text, expect String C (or B, depending on how far the count falls short) to come back empty rather than erroring - check your delimiter choice matches how the source string is actually formatted.

    Categoryadaptiveprompts/utils

    Inputs (4)

    NameTypeDefaultDescription
    textSTRINGThe input string to split.
    startINT00–99999Index of the first delimiter occurrence to split from.
    endINT10–99999Index of the second delimiter occurrence to split until.
    delimiterSTRING,The delimiter used to separate sections of the string.

    Outputs (3)

    NameTypeDescription
    String ASTRINGβ€”
    String BSTRINGβ€”
    String CSTRINGβ€”