Skip to main content

Text Replacement Helpers

Use text replacement helpers to extract or convert text. For example, a helper can pull a piece of information out of an email so you can use it in a ticket field.

There are four categories of text replacement helpers:

  • string helpers extract text before, after, or between specific strings
  • line helpers extract one or more lines of text
  • regex helpers extract text before, after, or between regular expressions, or extract strings that match a regular expression
  • date helpers convert date formats, add or subtract time, and convert between timezones

The structure of text replacement helpers​

Text replacement helpers are identifiers followed by zero or more parameters each separated by a space. Each parameter is itself an expression.

{{helper_name argument1 argument2 argument3 argument4=""}}
|-----------| |---------| |------------|
| | |
The name of the A positional A named
helper argument argument

For example, this expression uses the before_string helper to extract the portion of [email protected] before the first @, and returns john:

{{before_string '[email protected]' '@'}}

And since each parameter is itself an expression, we can change '[email protected]' to email.from.address like this:

{{before_string email.from.address '@'}}

We can even change '[email protected]' to another expression, nested in parentheses like this:

{{before_string (between_strings email.body "Email Address:" "\n") '@'}}

Denoting strings with quote marks​

Notice that the first example has single quotes around '[email protected]', and the second example has no quotes around email.from.address.

The quotes in the first example cause the before_string helper to use the literal text [email protected].

Without quotes, as in the second example, before_string treats email.from.address as a variable and uses its value. The second example first fills in the email sender's address, then extracts the part of that address before the @ sign.

The text replacement engine recognizes single quotes and double quotes as valid text delimiters in expressions. The following expressions all return the exact same text:

{{before_string '[email protected]' '@'}}
{{before_string "[email protected]" "@"}}
{{before_string "[email protected]" '@'}}
{{before_string '[email protected]' "@"}}