Skip to content

Regex Search and Match

Searches the input text using a regular expression and returns all matches. It uses Python’s regex engine to find non-overlapping matches in order, producing a list of results.
Preview

Usage

Use this node when you need to extract all substrings that match a pattern, such as extracting emails, hashtags, words of a certain length, or other structured tokens from text. Typically placed after a text generation or text input node to parse and collect specific elements.

Inputs

FieldRequiredTypeDescriptionExample
text_inputTrueSTRINGThe text to search for matches using the provided regular expression.The quick brown fox jumps over 2 lazy dogs.
regex_patternTrueSTRINGRegular expression pattern used to find matches. Supports Python regex syntax, including inline flags like (?i) for case-insensitive matching.\b\w{5}\b

Outputs

FieldTypeDescriptionExample
matchesLISTList of all non-overlapping matches found in the input text. If the pattern contains capture groups, each match may be a tuple of group values; otherwise, each match is a string.['quick', 'brown']

Important Notes

  • The matching behavior follows Python's re.findall: results are strings if there are no capture groups, or tuples if the pattern includes groups.
  • If no matches are found, the output is an empty list.
  • Regex flags are not separate inputs; use inline flags such as (?i) for case-insensitive or (?s) for dotall within the pattern.
  • Be mindful of escaping backslashes in patterns (e.g., use \b for word boundary in string literals).
  • Very large texts or complex patterns can impact performance; simplify patterns or pre-filter text when possible.

Troubleshooting

  • Pattern error (e.g., 'bad character range'): Ensure the regex is valid Python syntax and properly escaped.
  • Unexpected tuples in output: Remove capture groups or convert them to non-capturing groups using (?:...) to get full-match strings.
  • Case sensitivity issues: Add (?i) at the start of the pattern for case-insensitive matching.
  • No matches returned: Verify the pattern, test with simpler patterns, or check that the input text actually contains the target substrings.

Example Pipelines

Example
Example