This document explains the Find And Replace node, which allows you to search for and replace specific words, phrases, or patterns within text content.

Node Inputs

Required Fields

  • Input: The text content that will be processed for replacements

  • Replacements: A list of find/replace pairs to apply, with each pair containing:

    • Find word: The text to search for
    • Replace with: The text to use as replacement

Node Output

  • Output Text: The resulting text after all replacements have been applied

Node Functionality

The Find And Replace node searches for specific words, phrases, or patterns in text and replaces each occurrence with new text. It processes multiple replacements in a single operation, making it efficient for batch text editing tasks.

Key capabilities include:

  • Multiple replacements in one operation
  • Support for exact match replacements
  • Regular expression pattern matching

When to Use

The Find And Replace node is particularly valuable in scenarios requiring text transformation and standardization. Common use cases include:

  • Content Updating: Replace outdated terminology with current terms
  • Data Cleaning: Remove or replace unwanted characters and formatting
  • Text Standardization: Ensure consistent terminology across documents
  • Template Customization: Replace placeholder text with personalized content
  • Format Conversion: Transform data from one format to another

Some specific examples:

  • Replacing product names across marketing materials
  • Standardizing date formats in exported data
  • Removing sensitive information from documents
  • Converting between US and UK English spelling
  • Replacing placeholders like {{name}} with actual customer names

Using Regular Expressions

The node supports regular expressions (regex) for more advanced pattern matching. When using regex:

  • Regular expression patterns must be wrapped in forward slashes (/pattern/) with any flags at the end
  • Without the proper slashes, the node will treat the pattern as literal text

Regex Examples

  1. Basic Pattern Matching
Find word: /\d{3}-\d{2}-\d{4}/
Replace with: "[REDACTED SSN]"
Result: Replaces any SSN pattern (123-45-6789) with "[REDACTED SSN]"
  1. Case-Insensitive Matching
Find word: /apple/i
Replace with: "Orange"
Result: Replaces "apple", "Apple", "APPLE", etc. with "Orange"
  1. Global Replacement
Find word: /\s{2,}/g
Replace with: " "
Result: Replaces all instances of multiple spaces with a single space
  1. Capturing Groups
Find word: /(\d{2})-(\d{2})-(\d{4})/
Replace with: "$3-$1-$2"
Result: Converts "12-31-2023" to "2023-12-31"

Note: The regex pattern needs to be wrapped in / with any flags at the end, or the Find and Replace node won’t recognize it as a valid regex pattern.

Example Workflows

1. Template Personalization

Input: "Dear {{customer_name}}, Thank you for your order #{{order_number}}."
Find & Replace:
  - Find: "{{customer_name}}" → Replace: "John Smith"
  - Find: "{{order_number}}" → Replace: "ORD-12345"
Output: "Dear John Smith, Thank you for your order #ORD-12345."

2. Data Format Standardization

Input: "Phone: (555) 123-4567, DOB: 01/15/1980"
Find & Replace:
  - Find: "/\((\d{3})\) (\d{3})-(\d{4})/" → Replace: "+1-$1-$2-$3"
  - Find: "/(\d{2})\/(\d{2})\/(\d{4})/" → Replace: "$3-$1-$2"
Output: "Phone: +1-555-123-4567, DOB: 1980-01-15"

Loop Mode Pattern

Input: List of customer emails
Process: Replace standard placeholders with personalized information
Output: List of personalized emails ready to send

Important Considerations

  1. Replacements are processed in the order they are defined
  2. Multiple replacements can interfere with each other if not planned carefully
  3. Case-sensitive by default (use regex with ‘i’ flag for case-insensitive)
  4. Regex patterns require proper slashes (/pattern/) to be interpreted correctly

Additional Information

Video Tutorial

In summary, the Find And Replace node is a powerful text manipulation tool that can transform content according to specific patterns and requirements. Whether you need simple word substitution or complex pattern matching with regular expressions, this node provides the flexibility to handle diverse text processing needs.