What are the regular expressions or "regex"?

A regex (regular expression) is a sequence of characters that specifies a search pattern in any given text (string).

A text can consist of pretty much anything from letters to numbers, space characters to special characters. 

As long as the string follows some sort of pattern, regex is robust enough to capture this pattern and return a specific part of the string.

Regex use cases

Analytics Filters

The domain/app (contain or exclude) filters allow you to show metrics for specific domains or apps The filter’s regular expression rules to be as flexible as possible. The match is case insensitive.

Capture d’écran 2023-01-03 à 10.54.29

You can use this this regex "|" to :
  • Use a individual pattern (example : domain) : It will return all the domains using it.
  • Use multiple complete domains (example domain.com|domain.com) : It will return the domains used.
  • Use a list of patterns (domain1|domain2) : It will return the list of patterns

Compliance Reports 

In the compliance report settings, you can define the URL(s) you want to be integrated into the compliance report. You can use regex rules for that by selecting the regular expression option. Using a regular expression offers more flexibility in selecting URLs you don’t want to have in your reports.

Capture d’écran 2023-01-03 à 10.54.55

Test your regex before applying

We strongly encourage you to test your regex before applying them. You can use free tools such as https://regexr.com/.

Cheatsheet & examples

 

Character

Description

Regex Example

Texts Matched

Texts not matched

.

a placeholder that simply matches any character, even spaces, except newline

a.c

abc

baecc

abdc (two characters, instead of one, between a and c)

.*

matches all characters

test.*

testtest

test-version6

domain-test

domain-tes (t is missing)

^

matches at the beginning of the string

^debug

debug.domain.com

domain.debug (does not start by debug)

$

matches at the end of the string

.com$

domain.com

support.domain.com

domain.com.co (does not end by .com)

\/

/ need to have \ before

\/page2\/

/page2/

/page-v2/

[abc]

any of a, b, or c

test-[yv]

test-y

test-v

test-[yv] ([] are identified as regex pattern and not as characters)

ab|cd

match ab or cd

domain|support

dev.domain.com

subdomain.com

support.fr

mainsup (none of the two words are in the text)

^(ab|cd)

matches beginning with ab or cd

^(debug|preprod)

debug.domain.com

preprod.domain.com

domain.debug.com (debug is not at the start of the text)

(ab|cd)$

matches end with ab or cd

(.fr|.co.uk)$

domain.fr

sub.domain.fr

domain.co.uk

.fr.domain.com (.fr is not at the end)