Nodes/Bjornulf_custom_nodes/๐Ÿ”›๐Ÿ“ Match 10 Text to Input
ComfyUI Node

๐Ÿ”›๐Ÿ“ Match 10 Text to Input

Route data by matching a string, no If-Else chain needed

By justUmenยทCreated 2 years agoยทUpdated about a year agoยท 545
๐Ÿ”›๐Ÿ“ Match 10 Text to Input
  • input_1
  • input_2
  • input_3
  • input_4
  • input_5
  • input_6
  • input_7
  • input_8
  • input_9
  • input_10
  • *
โ—„input_textโ€”โ–บ
โ—„text_1โ–บ
โ—„text_2โ–บ
โ—„text_3โ–บ
โ—„text_4โ–บ
โ—„text_5โ–บ
โ—„text_6โ–บ
โ—„text_7โ–บ
โ—„text_8โ–บ
โ—„text_9โ–บ
โ—„text_10โ–บ
โ—„use_regextrueโ–บ

This is a switch statement for your graph. You give it one piece of text to check, up to ten candidate patterns to check it against, and up to ten values to route - whichever pattern matches, the corresponding value gets forwarded out the single output. Everything else gets dropped silently. It's the node you reach for when "if this text says X, use input A, otherwise use input B" starts turning into a stack of separate If-Else nodes.

A heads-up before anything else: this node isn't in the pack's README yet. Bjornulf_custom_nodes is under very active development - the author's own changelog is full of new nodes arriving faster than the write-up catches up - and this one looks like it landed after the last documented entry. Everything below comes straight from the node's own input/output definition rather than the author's description, so treat it as accurate-but-unofficial until the README catches up.

How it works

Wire your classifying string into input_text - that's the thing you're checking. Then, for as many of the ten slots as you need, fill in a text_N pattern and connect a matching input_N of whatever type you actually want routed (image, string, model, anything - the output is a generic wildcard type). When input_text matches one of your text_N patterns, the node forwards that slot's input_N value out. Nothing else fires.

The one setting worth understanding before you rely on this: use_regex, on by default. With it on, your text_N entries are treated as regular expressions tested against input_text, not plain string equality - so a pattern like cat|kitten will match either word, and stray regex metacharacters (., *, (, )) in a pattern you meant literally will do regex things instead of matching themselves. Turn use_regex off if you just want exact string matches and don't want to think about escaping.

The inputs and outputs that matter

  • input_text (required) - the string being checked against your patterns.
  • input_1 โ€ฆ input_10 (optional, any type) and text_1 โ€ฆ text_10 (optional strings, default empty) - up to ten paired candidates: if text_N matches input_text, input_N is what comes out.
  • use_regex (default true) - whether the text_N fields are regex or literal strings.
  • Output - a single wildcard-typed value: whichever input_N matched.

A natural pairing is an Ollama Talk or Ollama Vision response feeding input_text: have the model classify an image or a prompt into a word or two, then route to a different downstream branch (different LoRA, different checkpoint, different save folder) depending on what it said.

How to install it

Through ComfyUI Manager, search Bjornulf_custom_nodes and install, or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/justUmen/Bjornulf_custom_nodes

Then pip install -r requirements.txt from inside the cloned folder (a venv is the sane way to do this) and restart ComfyUI.

Common issues

Because use_regex defaults to on, the most common surprise is a pattern that "should" match failing to, because it contains a character regex treats specially. If a match you expect isn't firing, either escape the special character or flip use_regex off and use plain text. Beyond that, with no unmatched fallback described anywhere in the schema, plan for the case where none of your patterns hit - don't assume the node quietly passes something through by default if nothing matches.

Categorytext

Inputs (22)

NameTypeDefaultDescription
input_textSTRINGโ€”
input_1opt*โ€”
input_2opt*โ€”
input_3opt*โ€”
input_4opt*โ€”
input_5opt*โ€”
input_6opt*โ€”
input_7opt*โ€”
input_8opt*โ€”
input_9opt*โ€”
input_10opt*โ€”
text_1optSTRINGโ€”
text_2optSTRINGโ€”
text_3optSTRINGโ€”
text_4optSTRINGโ€”
text_5optSTRINGโ€”
text_6optSTRINGโ€”
text_7optSTRINGโ€”
text_8optSTRINGโ€”
text_9optSTRINGโ€”
text_10optSTRINGโ€”
use_regexoptBOOLEANtrueโ€”

Outputs (1)

NameTypeDescription
**โ€”