Nodes/ComfyUI_StringOps/提取标签之间🐠meeeyo.com
ComfyUI Node

提取标签之间🐠meeeyo.com

Pull the text trapped between two labels — the tag-between extractor

By MeeeyoAI·Created 2 years ago·Updated about a year ago· 209
提取标签之间🐠meeeyo.com
    • STRING
    input_string
    pattern标签始|标签尾

    Somewhere between a simple search and a full regex lies this node's whole personality: give it a start label and an end label, and it hands back everything sitting between them. ExtractSubstring (提取标签之间 - "extract between labels") is the ComfyUI_StringOps answer to a problem that shows up constantly once you start automating prompt files or parsing config-style text: the value you need is always surrounded by stuff you don't.

    How it works

    You feed it input_string and a single pattern field. The pattern is the trick - it holds two labels separated by a pipe: 标签始|标签尾 by default, i.e. "start label | end label". The node finds the start label, then grabs everything from just after it up to the end label.

    A few behaviors worth knowing:

    • If the end label isn't found, it falls back to the end of the line (newline), and if there's no newline, to the end of the whole string. So it's forgiving - missing closers won't nuke the run.
    • Empty lines inside the extracted block get stripped out of the result, which is handy for prompt lists and paragraphs.
    • If the start label never appears, you get back an empty string rather than an error.

    So input_string = "Hello 【world】 again" with pattern 【|】 returns world. Swap in your own labels and it's just that.

    Why you'd reach for it

    This is a prompt-engineering cleanup tool first. A common real-world setup: a text file or a node upstream gives you lines like scene: 【sunset beach】 camera: slow pan. You want the bit between the brackets to feed your video prompt, and the rest can go die. ExtractSubstring is one node instead of a regex you'll forget how to read in a week.

    It also composes well inside its own pack - run ExtractLinesByIndex to split a block, then ExtractSubstring per chunk to pull the labeled value out of each.

    Install

    Same pack install as everything else in StringOps:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MeeeyoAI/ComfyUI_StringOps.git
    

    Restart ComfyUI. (Or use ComfyUI Manager and search "ComfyUI_StringOps".) No model downloads, nothing unusual in requirements.txt - this is a pure Python string node. The UI is Chinese-labeled with the 🐠meeeyo.com branding and a contact ad in the description; the default pattern text is Chinese placeholder labels, so type your real labels in whatever language your text actually uses.

    Common issues

    The pipe is load-bearing. If you type a pattern without |, the node silently only uses the start half and the end label defaults to a newline - you'll get everything after your start label instead of the between-the-labels bit. Easy to do, confusing to debug. Second gotcha: it's literal matching, no regex. [ or ( in your labels is fine because they're matched as plain text - which is actually a plus, because the rule-based sibling node ExtractSpecificData treats brackets specially and catches people out.

    Third: because it strips empty lines, a "between" region that's genuinely empty returns empty. That's expected. Overall, it's the friendliest label-extractor in the pack, and the one I'd teach a beginner first.

    CategoryMeeeyo/String

    Inputs (2)

    NameTypeDefaultDescription
    input_stringSTRING
    patternSTRING标签始|标签尾

    Outputs (1)

    NameTypeDescription
    STRINGSTRING