Nodes/comfyui-flower-tools/🌸Flower 字串比對
ComfyUI Node

🌸Flower 字串比對

It finds a string inside another string — and tells you exactly where

By weichenglin0215·Created 8 months ago·Updated 2 months ago· 0
🌸Flower 字串比對
    • 位置
    • 是否有找到
    ◄字串A►
    ◄字串B►
    ◄比對模式從前面開始比對►
    ◄比對次數1►
    ◄區分大小寫true►

    Every serious ComfyUI workflow eventually needs a "does this text contain that text" check, and most people improvise it with logic nodes and a shrug. Flower String Comparison is the dedicated version of that: it tells you whether string B appears inside string A, and - the part most alternatives skip - where. The position output is what makes it more than a novelty.

    First heads-up, because it'll save you a confused five minutes: the node's UI is in Traditional Chinese. The display name on comfy.icu is "🌸Flower String Comparison", but the input fields are labeled 字串A (string A), 字串B (string B), 比對模式 (comparison mode), 比對次數 (comparison count), and 區分大小寫 (case-sensitive). Same node, same behavior - the labels just aren't localized. Worth knowing before you paste an English prompt and stare at a Chinese dropdown.

    How it works

    Under the hood it's Python's find / rfind - no AI, no API, nothing clever. You pick whether to scan from the front or the back, how many occurrences to skip, and whether matching is case-sensitive. The 比對次數 field is the interesting one: set it to 2 and it returns the second occurrence, so you can pull a specific token out of a repeated string. Outputs are 位置 (position, an INT, 0-based) and 是否有找到 (found or not, a BOOLEAN). Position comes back as -1 when there's no match, so "found" is just "position isn't -1" - you can wire either one and ignore the other.

    Where you'd actually use it

    • Gating: wire the BOOLEAN into a switch node - if the prompt contains "night", take the dark-lit branch.
    • Validation: check that a wildcard pick or an LLM-generated prompt didn't silently drop a required token.
    • Routing: use the position to feed a text-slicing step, since it tells you where the match sits rather than only that it exists.

    It's a plumbing-layer node, so set your expectations: it solves a tiny, specific problem and it solves it exactly once per execution. If you need to condition the whole graph on the result, pair the BOOLEAN with an rgthree-style switch - this node is the sensor, not the brain.

    Install

    It ships in the comfyui-flower-tools pack, so you get all ten Flower nodes in one go:

    cd ComfyUI/custom_nodes
    git clone https://github.com/weichenglin0215/comfyui-flower-tools.git
    

    …then restart ComfyUI. Or open ComfyUI Manager, search ComfyUI Flower Tools, and install from there. The pack's only hard pip dependency is opencc (used by the TCSC converter); this node itself needs nothing extra, no models, no downloads.

    Gotchas

    The position is 0-based - first character is index 0, so beginners frequently expect 1 and get confused. And remember the case-sensitivity toggle defaults to on: "night" won't match "Night". Turn 區分大小寫 off if you're matching user-typed text where casing isn't guaranteed. That's the whole failure surface - it's a small node with a small job, and honestly, the position output is the only reason to reach for it over a plain logic check.

    Categoryflower-tools

    Inputs (5)

    NameTypeDefaultDescription
    字串ASTRING—
    字串BSTRING—
    比對模式COMBO從前面開始比對2 options: 從前面開始比對, 從後面開始比對
    比對次數INT11–999—
    區分大小寫BOOLEANtrue—

    Outputs (2)

    NameTypeDescription
    位置INT—
    是否有找到BOOLEAN—