ComfyUI Node

prompt - search

Keep only the prompt tags that match

By YMC-GitHub·Created 3 years ago·Updated about a year ago· 20
prompt - search
    • STRING
    text
    search

    prompt - search is a filter, not a finder. Feed it a prompt and a search term, and it returns only the tags that contain that term - a prompt reduced to its matching subset. The obvious use is inspection ("what hair tags does this prompt actually have?"), but the smarter use is routing: extract the pose tags, then branch the workflow on whether they exist.

    It's one of the quieter nodes in the ymc text family, and honestly one of the more underrated ones. The pack's advanced sibling does the destructive operations (delete, move, replace); this one just looks.

    How it works

    Mechanically it's a per-tag substring match. The node splits your prompt on commas, and for each tag checks whether any of the comma-separated patterns in search appears inside that tag (before matching, tags are stripped of (parentheses) and :1.2 weights - so (white hair:1.1) matches a search for white hair). Tags that hit are kept, in original order; everything else is dropped.

    Two things to internalize:

    • It's substring, not exact-word. Searching hair matches white hair, long hair, and also hairpin. Useful and slightly dangerous in equal measure.
    • Any pattern in the search list can match. Comma-separate patterns and each tag is checked against all of them.

    The output is just a string - which means an empty result is an empty string, and that's a perfectly valid signal to branch on downstream.

    Inputs and outputs

    • text - the prompt to filter
    • search - comma-separated patterns; a tag survives if it contains any of them
    • STRING output - the matching tags, comma-separated, original order

    Installing it

    Part of ymc-node-suite-comfyui:

    • ComfyUI Manager → search ymc-node-suite-comfyui → Install → restart, or
    cd ComfyUI/custom_nodes
    git clone https://github.com/YMC-GitHub/ymc-node-suite-comfyui
    

    restart, and pip install -r requirements.txt on a manual clone (four yors_* helper libs; the pack's auto-install is commented out). No models, no GPU.

    Find it by canvas search (prompt / search) or the right-click ymc suite menu.

    Common issues

    • "It matched something I didn't want." Substring matching strikes again. cat matches catalog and black cat both. If you need exactness, search the full tag - or accept the fuzzy nature of this node.
    • "It returned nothing and I swear the tag is there." Check whitespace: long hair with a trailing space won't substring-match long hair... actually, since the tag is trimmed before matching, this is mostly handled - the more likely culprit is matching against a weighted tag form the search doesn't contain. (long hair:1.2) unweights to long hair before matching, so weights are handled.
    • WAS Node Suite conflicts on the pack's io/save nodes can show up as warnings if you run both packs - unrelated to this node.

    If you need the full edit toolkit - delete what matched, move it to the front, or replace it - step up to prompt - search (adv), which wraps this filter plus all the destructive actions into one node.

    Categoryymc suite/text

    Inputs (2)

    NameTypeDefaultDescription
    textSTRING
    searchSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING