Skip to content

Regex Search and Replace

Finds all substrings in the input text that match a regular expression and replaces them with the provided replacement text. Performs a global replace using standard regex rules, returning the fully transformed string.
Preview

Usage

Use this node when you need to sanitize, format, or transform text based on patterns (e.g., masking emails, normalizing IDs, replacing tokens). Place it after any node that produces text and before nodes that consume the cleaned or reformatted string.

Inputs

FieldRequiredTypeDescriptionExample
text_inputTrueSTRINGThe source text where regex matches will be searched and replaced.Contact me at john.doe@example.com for details.
regex_patternTrueSTRINGRegular expression pattern used to find matches. Uses standard Python-style regex syntax.\b\w+@\w+\.\w+\b
replacement_textTrueSTRINGText to insert in place of each match. Backreferences like \1, \2 can be used to reinsert captured groups.

Outputs

FieldTypeDescriptionExample
replaced_textSTRINGThe resulting text after applying regex-based replacements across the entire input.Contact me at for details.

Important Notes

  • Global replacement: All matches are replaced; there is no option to limit the number of replacements.
  • Regex syntax: Patterns follow standard regex rules. Flags like case-insensitivity are not exposed; embed inline flags in the pattern if needed (e.g., (?i) for case-insensitive).
  • Escaping: Remember to escape backslashes in patterns and replacements when entering them as strings (e.g., \d, \b).
  • Backreferences: You can reference captured groups in the replacement text using \1, \2, etc.
  • No multiline/flags inputs: Multiline or DOTALL behavior must be encoded in the pattern itself using inline modifiers.
  • Large text performance: Very large inputs or highly complex patterns can impact performance.

Troubleshooting

  • Invalid regex pattern error: If the node fails, verify the pattern is valid and properly escaped. Test simpler patterns first.
  • Unexpected replacements: Ensure your pattern is specific enough and uses anchors or word boundaries (e.g., \b) where appropriate.
  • Backreference not working: Confirm your pattern defines capturing groups with parentheses and that you reference them correctly (\1, \2).
  • No changes in output: Check that the pattern actually matches the input; try testing with a known-matching sample or relax the pattern.
  • Case sensitivity issues: Add inline flags like (?i) at the start of the pattern for case-insensitive matching.

Example Pipelines

Example
Example