Text Replace
Find-and-replace, but the 'find' is a regex, which is both the power and the trap
- result_text
- replacement_count_number
- replacement_count_float
- replacement_count_int
VixTextReplace is a search-and-replace node for strings, with a twist that trips up basically everyone the first time: the find field is a regular expression, not plain text. Type dog and it works like you expect. Type . and it replaces every character in your string, because in regex . means "anything." That one behavior is the whole difference between this node being handy and it silently mangling your prompt.
It's part of the ComfyUI-Visionatrix pack - same family as the text utilities the Visionatrix team bundles for their flow system - but like most of the pack's Text nodes it's plain ComfyUI text surgery with no Visionatrix dependency. And a heads-up: like VixTextConcatenate, it's marked deprecated in the pack source, so ComfyUI shows a warning when you load a workflow that uses it.
Inputs and outputs
Three required inputs:
- text - the string to modify, typically wired from another node.
- find - the regex pattern to search for.
- replace - the replacement text. Standard Python regex substitution applies, so
\1refers back to a capture group - replace"(.)(.)"with\2\1to swap adjacent characters. A little regex knowledge goes a long way here.
The outputs are generous, which is the interesting part:
- result_text (STRING) - the modified string.
- replacement_count_number, replacement_count_float, replacement_count_int - the number of replacements, emitted in all three numeric types because the author didn't want you to care which type your downstream node wants. Plug the INT one into anything that needs a count and you're done.
How it works
It's a one-liner under the hood: re.subn(find, replace, text), which returns both the substituted string and the count. Python's regex engine does all the heavy lifting. No model, no dependencies beyond the standard library.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/Visionatrix/ComfyUI-Visionatrix
Then restart ComfyUI, or install ComfyUI-Visionatrix via ComfyUI Manager. No model downloads, and the dependencies are the stock torch/pillow/numpy trio that's already there.
Where people get burned
The regex thing is the headline, so let me be specific. If your find is meant to be literal, escape the metacharacters: . becomes \., $ becomes \$. The classic failure is someone building a prompt-cleaning workflow, typing , - which is fine - then later typing . and watching every character in the prompt collapse into commas. Also remember re.subn replaces all non-overlapping matches, so there's no "replace first only" mode.
And the deprecation caveat: for a fresh project, use ComfyUI's built-in String Replace or a text utility from WAS Node Suite instead, and you won't start out with a node ComfyUI warns about. This one is best understood as "old shared workflow? okay, I know what this does now" - and knowing the regex semantics is how you read what the workflow author was actually doing.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| find | STRING | — | |
| replace | STRING | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| result_text | STRING | — |
| replacement_count_number | NUMBER | — |
| replacement_count_float | FLOAT | — |
| replacement_count_int | INT | — |