Nodes/comfyui-moonpack/Regex String Replace (legacy)
ComfyUI Node

Regex String Replace (legacy)

The v0.1 key that still runs the same regex

By moonwhaler·Created about a year ago·Updated 11 days ago· 16
Regex String Replace (legacy)
    • text
    • match_count
    text
    pattern
    replacement
    case_insensitivefalse
    multilinefalse
    dotallfalse
    test_modefalse

    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.

    CategoryMoonPack/string

    Inputs (7)

    NameTypeDefaultDescription
    textSTRINGSource text.
    patternSTRINGPython regex pattern.
    replacementSTRINGReplacement string. Use \1, \2, … for capture groups.
    case_insensitiveoptBOOLEANfalseApply re.IGNORECASE.
    multilineoptBOOLEANfalseApply re.MULTILINE (^/$ match line boundaries).
    dotalloptBOOLEANfalseApply re.DOTALL (. matches newlines).
    test_modeoptBOOLEANfalseHighlight matches with >>>…<<< instead of replacing.

    Outputs (2)

    NameTypeDescription
    textSTRING
    match_countINT