Regex Search and Replace¶
Performs regex-based search and replace on input text, or extracts all matches using a regular expression pattern.
Quick Start¶
- Add the Regex Search and Replace node to your workflow.
- Enter the input text and regex pattern.
- Specify replacement text (for replace) or leave blank (for match).
- Run the node to get replaced text or a list of matches.
Setup Guide¶
1. Add Node to Workflow¶
- Open your node editor.
- Drag the Regex Search and Replace node into your workspace.
2. Configure Inputs¶
- Enter the text to process.
- Provide a valid regex pattern.
- (For replace) Enter the replacement text.
Basic Usage¶
Find and Replace¶
- Replace all matches of a regex pattern in a string.
- Example: Replace all 5-letter words with "#####".
Find Matches¶
- Extract all substrings matching a regex pattern.
- Example: Find all 6-letter words in a paragraph.
Configuration¶
Required Inputs¶
Field | Description | Type | Example |
---|---|---|---|
text_input | The input text to process | STRING | "Hello world" |
regex_pattern | Regular expression pattern to match | STRING | "\b\w{5}\b" |
replacement_text | Text to replace each match (replace only) | STRING | "#####" |
Optional Inputs¶
None
Outputs¶
Field | Description | Example |
---|---|---|
replaced_text | Text after replacements (replace node) | "##### world" |
matches | List of all matches (match node) | ["sample", "string"] |
Best Practices¶
Regex Patterns¶
- Test your regex pattern before use.
- Use raw strings (prefix with r) to avoid escape issues.
Usage Tips¶
- For complex replacements, verify the output with sample data.
- Use specific patterns to avoid unintended matches.
Troubleshooting¶
Common Issues¶
- No matches found: Check your regex pattern for accuracy.
- Unexpected replacements: Ensure the pattern does not match unintended text.
Need Help?¶
- Refer to Python's
re
module documentation for regex syntax. - Use online regex testers to validate your patterns.