Nodes/ComfyUi-MpiNodes/Mpi Text Contains
ComfyUI Node

Mpi Text Contains

A prompt whitelist check that actually understands plurals

By MadPonyInteractive·Created 11 months ago·Updated 5 days ago· 3
Mpi Text Contains
    • boolean
    text
    words

    You want the graph to branch based on what's in the prompt - add a LoRA only when the prompt mentions the style it belongs to, refuse a prompt that says a banned word, or conditionally route based on a tag. MpiTextContains is the test for that: give it text and a list of words, and it returns a single BOOLEAN - true if any of your words appears in the text.

    The useful part is that it's not a dumb substring check. It matches whole words, so cat finds "a CAT sits" and "two cats" but not "catalogue". It's case-insensitive. Phrases ignore spacing - bird in a tree still matches even if the prompt wraps across a line break. And it's plural-aware for the regular cases: box finds "boxes", baby finds "babies". Irregular plurals (child/children) need their own line, because the plural logic is rule-based, not a dictionary.

    Mechanically it's a hand-built regex: each word is escaped and anchored with \b, plurals get an optional s (or es, or yies), and multi-word phrases collapse any run of whitespace to \s+. The result is a check that survives the messy reality of real prompts instead of breaking on a comma or a newline.

    The inputs that matter

    • text - the string to search (a wired prompt, usually).
    • words - your whitelist/blacklist, separated by commas or new lines. The multiline box is exactly for this: paste a list of tags and go.

    Output: boolean. Wire it into an if/else, a blocker, or the pack's switches to gate a branch. Classic use: MpiStyleSelector chooses a style, and a MpiTextContains on the resulting prompt confirms the style's trigger actually made it through before the LoRA branch fires.

    Install

    Part of ComfyUi-MpiNodes. ComfyUI Manager (search "MpiNodes" / publisher "mad-pony-interactive"), or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MadPonyInteractive/ComfyUi-MpiNodes
    

    Restart. No extra deps.

    Where people get surprised

    The plural handling is regex heuristics, so it has edges: irregular plurals like child/children, knife/knives, mouse/mice will not match each other - the README is explicit that those need their own entry, and the tooltip on words says the same. And because it's whole-word matching with \b, punctuation is your friend rather than your enemy: cat, and (cat) both match cat. If you need substring matching (find "cat" inside "catalogue"), this isn't the node - that's a find_string/replace_string job. An empty words list returns False, which is the safe direction for a whitelist gate.

    CategoryMpiNodes/Logic

    Inputs (2)

    NameTypeDefaultDescription
    textSTRING
    wordsSTRINGWords or phrases to look for inside text, separated by commas or new lines. Case-insensitive, whole words only ('cat' matches 'cat' and 'cats' but not 'catalogue'). Phrases ignore spacing, so 'bird in a tree' matches across line breaks. Irregular plurals (child/children) need their own entry.

    Outputs (1)

    NameTypeDescription
    booleanBOOLEAN