Regex Search and Replace¶
Performs a regular-expression-based search and replace on the provided text. It replaces all occurrences that match the pattern with the specified replacement text using Python's regex syntax. Useful for cleaning, transforming, or masking parts of text.

Usage¶
Use this node when you need to transform text by pattern—e.g., redact emails, normalize formatting, or substitute tokens. Provide the input text, a valid regex pattern, and the replacement string; the node outputs the fully replaced text. Integrate it before downstream nodes that require cleaned or standardized inputs.
Inputs¶
| Field | Required | Type | Description | Example |
|---|---|---|---|---|
| text_input | True | STRING | The source text in which to search for matches and perform replacements. | Contact me at john.doe@example.com or jane@example.org. |
| regex_pattern | True | STRING | The regular expression to match. Uses Python regex syntax; inline flags like (?i) for case-insensitive are supported. | \b[\w.%+-]+@[\w.-]+\.[A-Za-z]{2,}\b |
| replacement_text | True | STRING | Text to replace each match. Supports backreferences such as \1, \2 corresponding to capturing groups in the pattern. |
Outputs¶
| Field | Type | Description | Example |
|---|---|---|---|
| replaced_text | STRING | The resulting text after applying the regex replacement to all matches. | Contact me at |
Important Notes¶
- Pattern syntax: Follows Python regular expression rules; ensure proper escaping of backslashes in patterns.
- Global replacement: All matches in the input are replaced (not just the first).
- Backreferences: Use \1, \2, etc., in the replacement to insert captured groups.
- Inline flags: Use inline modifiers (e.g., (?i) case-insensitive, (?m) multiline) within the pattern if needed; there is no separate flags input.
- Escaping in UI/JSON: Remember to double-escape backslashes (e.g., \d) when entering patterns in JSON-like fields.
Troubleshooting¶
- Invalid pattern error: If execution fails, verify the regex is valid and properly escaped (e.g., use \b instead of \b in JSON strings).
- Unexpected replacements: Add anchors (^, $), word boundaries (\b), or use non-greedy quantifiers (e.g., .*?) to constrain matches.
- Case sensitivity issues: Add (?i) at the start of your pattern for case-insensitive matching.
- Group references not working: Ensure your pattern includes capturing groups (parentheses) and reference them correctly in the replacement (e.g., \1).
- Performance on large text: Complex patterns on very large strings may be slow; simplify the regex or narrow the scope where possible.
Example Pipelines¶