It’s live! Access exclusive 2024 live chat benchmark data & see how well your team is performing.

Get the data
How to Set Up Regular Expression

A regular expression is a sequence of characters that forms a search pattern. When you search for data in a text, you can use the search pattern to describe what you want to search for. A regular expression can be a single character or a complicated search pattern. You can use it to perform all types of text search operations on the Subject and Body of the email. 


Basic Regular Expression Characters

The regular expression uses character classes, special characters, and quantifiers to create more elaborate and extensive searches to allow the user to expand their search.

Character classes tell the regex engine to match only a certain set of characters, such as digits, whitespace, or words.

\sMatch any character which is considered whitespace.
\dMatch any character which is a digit ( 0 - 9 ).
\wMatch any character which is a word character ( A-Z, a-z, 0-9 and _ ).
\SMatch any character which is not whitespace.
\DMatch any character which is not a digit.
\WMatch any character which is not a word character.

Special characters are characters that are reserved for special use. These characters expand the use of regex.

dot or period .
Match any single character.
vertical bar or pipe |
Functions as a boolean "or".
brackets[ ]
Match a range of characters contained within the square brackets.
parentheses ()
Capture everything enclosed within the parentheses.
curly brackets {}Acts as a quantifier.
dollar sign $
End of a string or line.
backslash \
Escapes, or remove the special meaning of the next character. Useful for when you are searching for these special characters.

Quantifiers tell the regex engine how many or how few characters to search for.

*
Match zero or more of the preceding item.
+
Match one or more of the preceding item.
?
Match zero or one of the preceding item.
{n}Match exactly n of the preceding item.
{n,m}
Match between n and m of the preceding item.
{n,}Match n or more of the preceding item.


Sample Regular Expression

The following are the samples that you can refer to using the regular expression for the Email channel.

  • Search for an Order
  • Search for a Report
  • Search for an Invoice


Search for an Order

In the Regular Expression text field, provide the following pattern: order id:[0-9]+ 

kb-regexp-03.png

Let us consider that the client's email subject string is: What is the update on order id:787846.

Comm100 runs the regular expression on the string: What is the update on order id:787846 and provides the matched output of the pattern from within the string, that is: order id:787846


Search for a Report

In the Regular Expression text field, provide the following pattern: report id salesforce_[0-9]+

kb-regexp-04.png Let us consider that the client's email body string is: Let me know the data from the report of report id salesforce_797000773.

Comm100 runs the regular expression on the string: Let me know the data from the report of report id salesforce_797000773, and provides the matched output of the pattern from within the string: report id salesforce_797000773


Search for an Invoice

In the Regular Expression text field, provide the following pattern: item_type:|electronics|mobile

kb-regexp-05.png

Let us consider that the string in the client's email body is: Please provide the invoice for item_type: mobile and electronics and the warranty information.

Comm100 runs regular expression on the string: Please provide the invoice for item_type: mobile and electronics in addition to the warranty information, and provides matched output of the pattern from within the string, that is: Please provide the invoice for item_type: mobile and electronics in addition to the warranty card.

To learn how to build, debug, and test your regular expression, see regex101.