Regex Editor
A regex node that doesn't make you memorize the pattern
- match
Most regex nodes make you write the pattern. That's the hard part for most people, and it's where the Regex Editor from iTools is genuinely nice: it ships a dropdown of 27 ready-made patterns - email, phone_number, digit, whitespace, word_character, contains_hello, cat_or_dog, starts_with_abc, double_quoted, in_parentheses and friends - and picking one fills the pattern field for you. You still get a custom slot for your own pattern; the presets are the boring, reliable ones, not clever foot-guns.
Reach for it when you need to pull something out of a text or reshape a prompt line: extract the number from a batch label, strip quoted segments, transform a list of prompts into variations. It's a string-in / string-out utility, so it slots into prompt pipelines right before a CLIPTextEncode.
How it works
Python's re module is the engine, so it's Python regex syntax, not JavaScript's - remember that when you're porting a pattern you found on Stack Overflow. Behavior is split into four modes, controlled entirely by which replacement fields you fill:
- Both
replace_matchandreplace_non_matchempty → returns all matches, joined with no separator. replace_matchset only → every match is swapped for the replacement (a globalre.sub).replace_non_matchset only → matches survive, everything around them becomes the replacement.- Both set → a full swap: matches become
replace_match, the gaps between them becomereplace_non_match.
Nice touch: the node relabels its output pin (match, replace, replace_non_match) depending on which mode you're in, so you're not guessing what the output means.
Inputs and outputs
text_in(STRING) - the text to chew on. Forced as an input, so you can wire it from upstream nodes.regex_pattern(STRING) - the pattern; the picker writes here, or type your own.pattern_picker(enum, defaultcustom) - the 27-preset dropdown.replace_match/replace_non_match(STRING) - the mode switches above.- Output:
match(STRING).
Install
Part of the iTools pack - no separate install. ComfyUI Manager: search ComfyUI-iTools, install, restart, or clone it:
cd ComfyUI/custom_nodes
git clone https://github.com/MohammadAboulEla/ComfyUI-iTools
No requirements.txt, no models, nothing to download. It lives under the iTools category in the node menu.
Where people get burned
Three things bite. First, when both replace fields are empty, matches come back concatenated with no separator - extracting three things from a line gives you one run-together blob, so put a delimiter in the pattern if you need the pieces separate. Second, output is .strip()-ed, so leading/trailing whitespace gets silently eaten. Third, the phone_number preset is anchored with ^…$, which assumes your whole text is the phone number - running it against a multi-line list matches nothing. If that trips you up, use a custom pattern without the anchors. And when you're swapping matches in prompt text, remember Python regex treats ( and ) as groups - use the Text Replacer sibling node when you mean literal parentheses like (word:1.3).
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| text_in | STRING | — | |
| regex_pattern | STRING | — | |
| pattern_picker | COMBO | custom | 27 options: custom, contains_hello, cat_or_dog, starts_with_abc, ends_with_xyz, any_character, +21 |
| replace_match | STRING | — | |
| replace_non_match | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| match | STRING | — |