Nodes/ymc-node-suite-comfyui/prompt - search (adv)
ComfyUI Node

prompt - search (adv)

Search, delete, reorder or replace tags in one pass

By YMC-GitHub·Created 3 years ago·Updated about a year ago· 20
prompt - search (adv)
    • STRING
    text
    search
    action
    replace

    This is the workhorse of the ymc prompt family - the one node that does search, delete, reorder, and replace, all behind a single action dropdown. If you only install one prompt-editing node from this pack, make it this one. It's prompt - search (the pure filter) with teeth.

    The killer use case is ordering. On SDXL-lineage anime models, earlier tags get stronger attention - so "move my character and pose tags to the front" is a real quality lever, not a cosmetic one. This node does that in one click, and it can also strip a whole category of tags or rename a tag everywhere it appears.

    How it works

    The flow is always: search first, then act. The node finds every tag in text that contains any pattern from the comma-separated search list (matching is substring-based, and tags are unweighted before comparison, so (1girl:1.2) still matches 1girl). Then action decides what happens to those matched tags:

    • search - just return the matches (same as plain prompt - search)
    • del - remove the matched tags from the prompt
    • move2head - move matched tags to the front, rest follows in order
    • move2tail - move matched tags to the back
    • replace - swap every matched tag for the replace string
    • none - return text unchanged (a bypass)

    Because each action starts from the same search, the same search/text pair can feed several of these nodes with different actions - a quick way to see "what would this prompt look like without hair tags" vs "with hair tags first" without editing anything.

    Inputs and outputs

    The ones you'll actually set:

    • text - the prompt to edit
    • search - the comma-separated patterns that select tags
    • action - one of the six operations above
    • replace - the string used when action is replace

    Single STRING output: the transformed prompt.

    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; auto-install is commented out). No models, no GPU.

    Search prompt / search on the canvas or use the right-click ymc suite menu.

    Common issues

    • Substring matching bites twice. move2head with hair also moves hairpin. Check what actually matched by running action = search first and eyeballing the output - that's the built-in debug step.
    • replace replaces whole tags, not substrings. Searching hair and replacing with fur turns long hair into fur (the whole tag is swapped), not long fur. If you want in-tag edits, you're in the wrong node.
    • Empty matches are harmless. If nothing matches, del/replace/move* all return the prompt essentially unchanged - safe to leave wired up.
    • WAS Node Suite conflicts on the pack's io/save nodes can appear as Manager warnings if you run both packs - unrelated to this node.

    For plain deletion only, the pack's prompt - del is simpler; for a pure filter, prompt - search. But the moment you want to reorder or replace, this is the one.

    Categoryymc suite/text

    Inputs (4)

    NameTypeDefaultDescription
    textSTRING
    searchSTRING
    actionCOMBO6 options: none, del, move2head, move2tail, replace, search
    replaceSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING