Skip to main content

Perform a Regular Expression Match

The Perform a Regular Expression Match action uses a regular expression to extract one or more portions of text from a string. Use named capture groups to extract specific values as named variables.

This action is useful for identifying text that matches a specific pattern, such as a serial number, ticket number, email address, or phone number.

When to Use This Action

Use this action when:

  • You need to extract one or more values from text using a pattern
  • You want named capture groups to give extracted values meaningful property names
  • You need to find all occurrences of a pattern in a string

Don't use this action for:

Configuration

FieldDescription
PatternThe regular expression pattern to match. Must be a valid PCRE2 regular expression including a starting delimiter, ending delimiter, and optional flags. Use named capture groups to extract values.
SubjectThe text to match against. Supports text expressions with {{variable}} syntax.
Return all matchesWhen enabled, returns an array of objects, one for each match found. When disabled (default), returns only the first match as a single object.

Pattern Examples

  • /(?<TicketNumber>T20[0-9]{6}\.[0-9]{4})/ (extracts an Autotask ticket number)
  • /(?<Phone>\+?[\d\s\-\(\)]{7,})/ (extracts a phone number)
  • /(?<Domain>@[\w\-]+\.[\w\-]+)/ (extracts an email domain)
  • /Priority:\s*(?<Priority>\w+).*Category:\s*(?<Category>\w+)/is (extracts multiple values at once)

Subject Examples

  • {{email.subject}} to match against the email subject
  • {{email.body}} to match against the email body
  • {{custom.previousResult}} to match against a previously extracted value

Returned Variables

When you configure Store the results in Variable, the matched named capture groups are returned as object properties.

Single match (Return all matches disabled):

VariableTypeDescription
<GroupName>stringThe value captured by each named group (e.g., TicketNumber)

All matches (Return all matches enabled):

VariableTypeDescription
[0].<GroupName>stringThe first match's captured group value
[1].<GroupName>stringThe second match's captured group value, etc.

Example: If you name your variable TicketRegex and your pattern includes (?<TicketNumber>...), access the extracted value as {{custom.TicketRegex.TicketNumber}}.

Example Use Cases

Extract Autotask Ticket Number

Extract a ticket number from an email subject:

Pattern: /(?<TicketNumber>T20[0-9]{6}\.[0-9]{4}(\.[0-9]{3})?)/
Subject: {{email.subject}}

If stored as TicketRegex, access as {{custom.TicketRegex.TicketNumber}}.

Extract Multiple Values at Once

Pattern: /Priority:\s*(?<Priority>\w+).*Category:\s*(?<Category>\w+)/is
Subject: {{email.body}}

Returns {{custom.parsed.Priority}} and {{custom.parsed.Category}}.

Notes

  • If no match is found, the variable is empty/null
  • Named capture groups ((?<name>...)) are required to access extracted values as named properties
  • Unnamed capture groups are not accessible as named variables