Regex String Replace (legacy)
The v0.1 key that still runs the same regex
- text
- match_count
You've got a RegexStringReplace node in a workflow and the menu shows it as "(legacy)" - that's MoonPack's old registry key, kept as an alias since v0.2 renamed everything to the MoonPack_ prefix. The current node is MoonPack_RegexStringReplace, and it is the same code underneath. This page is the short version plus the rename warning; the long version lives on the current node's page.
Quick recap: it's Python-regex find-and-replace with text, pattern, and replacement inputs, \1/\2 capture-group references, and toggles for case_insensitive, multiline, and dotall. The feature that sells it is test_mode - flip it on and matches get wrapped in >>>...<<< instead of replaced, so you can see what your pattern hits before committing. Outputs are text and match_count; a count of zero means your pattern matched nothing, which is usually the first thing to check when a replace "doesn't work."
The rename thing, again
Same story as the other legacy keys in this pack: v0.1 registered the node as RegexStringReplace, v0.2 moved it to MoonPack_RegexStringReplace, and the old key is registered as an alias for one release cycle so your saved workflows don't break. The README says aliases are scheduled for removal in 1.0. The fix is the same one-save migration: load the workflow, save it once, and it writes back with the new key. Two clicks, done, and you're safe from the cleanup.
Installing it
It's part of MoonPack, so:
cd ComfyUI/custom_nodes
git clone https://github.com/moonwhaler/comfyui-moonpack.git
or ComfyUI Manager → MoonPack → install, restart. Under MoonPack/string. No models, no extra Python dependencies.
Bottom line
Nothing about the node is deprecated - only the name. Keep using it, do the migration save, and move on with your regexing.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | Source text. | |
| pattern | STRING | Python regex pattern. | |
| replacement | STRING | Replacement string. Use \1, \2, … for capture groups. | |
| case_insensitiveopt | BOOLEAN | false | Apply re.IGNORECASE. |
| multilineopt | BOOLEAN | false | Apply re.MULTILINE (^/$ match line boundaries). |
| dotallopt | BOOLEAN | false | Apply re.DOTALL (. matches newlines). |
| test_modeopt | BOOLEAN | false | Highlight matches with >>>…<<< instead of replacing. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| match_count | INT | — |