Nodes/ComfyUI-Muye-nodes/文本按分隔符分割
ComfyUI Node

文本按分隔符分割

Split text on any delimiter — and strip those <think> blocks

By muyexiuluo·Created about a year ago·Updated 23 days ago· 89
文本按分隔符分割
    • 总列表
    • 选中列表的完整分割
    • 选中段落
    输入来源文本框
    输入文本
    分隔符<think>
    使用正则表达式false
    输出段落索引1
    输出列表索引1
    总列表段落选择0
    外部文本列表

    The default delimiter here is <think>, and that tells you exactly what the author built this for. Reasoning LLMs - Qwen, DeepSeek, the whole chain-of-thought family - wrap their deliberation in <think>...</think> blocks, and if you're feeding their output into a prompt or a caption pipeline, that scratch work bleeds straight into your results. The KB's LLM-in-ComfyUI doc flags this as the #1 failure mode of LLM prompt nodes: reasoning models leak their scratch-work into your prompt. TextSplitByDelimiterEnhanced is the surgical answer - split on the delimiter, throw away the block you don't want, keep the rest.

    Under the hood it's a proper little list-processing node, not just a one-liner. It takes text from a 文本框 directly or from an 外部文本列表 (a list of strings, e.g. a batch of LLM outputs), and splits each one on your 分隔符 - optionally treating it as a 使用正则表达式 when you need something more clever than a literal match. Then it hands you three outputs:

    • 总列表 - every segment from every input, concatenated into one list. Turn this on its own if you just want "all the pieces."
    • 选中列表的完整分割 - the complete split of one specific input list item (chosen by 输出列表索引).
    • 选中段落 - a single segment pulled out (chosen by 输出段落索引), which is the one you actually feed into a prompt or caption.

    The index fields are the slightly fiddly part, and they're 1-based: 1 is the first list item or segment, and 0 returns an empty output. So to strip a think-block you'd split on <think> (and </think> if needed), then use 选中段落 with the index of the segment after the block. It also supports the "grab the Nth segment from every input item" trick via 总列表段落选择 - useful when every caption in a batch has the same structural shape and you want the same field out of each.

    One behavioral note: empty segments are dropped. If your delimiter appears twice in a row or at the edges, you won't get blank strings back - just the content. Keep that in mind if you were expecting positional alignment with the raw text.

    Install

    ComfyUI Manager → search "muye" → install "ComfyUI-Muye-nodes", restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/muyexiuluo/ComfyUI-Muye-nodes
    cd ComfyUI-Muye-nodes
    pip install -r requirements.txt
    

    then restart. Pure Python standard library (just re) - no extra deps. The README's manual block references an older ComfyUI_Muye.git URL; use the -nodes one above. Display name is 文本按分隔符分割, labels in Chinese (分隔符 = delimiter, 使用正则表达式 = use regex). If the node's missing, check the console for [Muye] Failed to load module.

    The pair it's meant for

    This pack also ships the captioning nodes (Qwen2.5-VL / Qwen3-VL / LLaVA) whose output this was built to clean. If you're running those and seeing reasoning noise in your captions, this node is the designated scrubber - split on <think>, keep the tail, feed the result to BatchTextReplace for final polish. That's a genuinely coherent little pipeline, which is more than most grab-bag packs can say.

    CategoryMuye/文本

    Inputs (8)

    NameTypeDefaultDescription
    输入来源COMBO文本框2 options: 文本框, 外部列表
    输入文本STRING
    分隔符STRING<think>
    使用正则表达式BOOLEANfalse
    输出段落索引INT10–100
    输出列表索引INT10–100
    总列表段落选择INT00–100
    外部文本列表optSTRING

    Outputs (3)

    NameTypeDescription
    总列表STRING
    选中列表的完整分割STRING
    选中段落STRING