Syntax for Regular Expression

In Automation, you can use Regular Expressions (regex) to match certain conditions like a URL or Event data/properties.

What is a regular expression

A regular expression is a sequence of characters that specifies a search pattern. For example, you might want to match all the URL that start with https:// or http://, with /account/ in the middle and ending by the client's account number which is a 6-digit number. If you want to do a complex search like this, you'll have to use regular expressions.

For complex needs, please make sure to ask your developer to help you build the regex. If you wish to know more about Regular expressions, you can check this article.

We've gathered a few examples on how to use regex, but you'll find a lot of information more on the internet, with Regex validators to check if your regex is correct. 

Examples

Expression Description

[account]

 

Find any character between the brackets
I want to find account in my URL

[^abc]

 

Find any character NOT between the brackets
I don't want my URL to contain cart > [^cart]

[0-9]

 

Find any character between the brackets (any digit)
I want to find the account number (6-digit) >

[0-9]{6}
[0-9] : Character class to match one of the 10 digits
{6} : Range quantifier 6

[^0-9]

 

Find any character NOT between the brackets (any non-digit)

(x|y)

 

Find any of the alternatives specified

I want the URL to have either .com or .fr > (.com|.fr)

^sendinblue 

begins with "sendinblue"

sendinblue$ 

ends with "sendinblue"

^sendinblue$ 

is exactly "sendinblue"

[^i*&2@] 

contains any character other than an i, asterisk, ampersand, 2, or at-sign.

SIB[0-9]{6-12}

I want to find the client number which starts with SIB and has between 6 to 12 digits after (e.g SIB34562788)