Regex (Regular Expression)

What is it?

A Regular Expression (often shortened to Regex) refers to a string of text used to match a particular pattern. Regex is particularly useful for defining URL locations. The Regex string is coded according to a specific syntax, and the goal is to be able to cover more ground with a single line of text rather than having to write multiple lines.

What is it used for?

In conversion rate optimisation, Regex is essentially used to define locations on your site where a project should be running or tracking conversions.

What are the benefits?

The most obvious benefit is a gain of time when defining the locations of your tests/conversions, particularly in a multiple-location scenario. But in some cases where a URL dynamically updates according to data input on the page by a user (for instance, an airlines’ search results page may contain dynamic details about the chosen origin/destination airports, the outbound/inbounds dates, etc.), Regex will be a life saver as you could not otherwise cover all the potential combinations that can appear in the URL.

What can you do with it?

With Regex, you can refine matching down to the exact character/word/string you need, or go broad and catch much wider expressions. All you need to do is learn the basic syntax, which can easily be done with free online tutorials.

Examples of Regex in use

Let’s imagine you want to run a test on product pages only and have the following URL pattern for those pages:


In this instance, the integer element refers to a potential product ID and will change for every single product page.

If you want your AB test to run on all product pages, there’s no need to list every single product ID manually. You can capture all product pages and their product IDs in one go with the following Regex:


The “.*”will capture any text that comes after the “/product/” string, encompassing all product IDs and therefore all product pages.

More from the glossary

Reporting Dashboard

Reporting Dashboard What is a Reporting Dashboard? A reporting dashboard contains current data and highlight specified metrics in visually appealing

Read More »


Targeting What is Targeting? Targeting consists in showing specific visitors a certain piece of content based upon pre-defined criteria, such

Read More »

Get in touch

If you have more questions or want to know a little more about website optimisation and personalisation, send us a message or call us on 0333 444 5502.

Thank you!

Thanks for submitting your enquiry with us.
A member of the team will be in touch shortly to follow up with you.

Thank you!

Please check your inbox and validate your email address so that we can create your free trial account.

Training Videos

While we're setting up your account, feel free to check out our training videos. You'll find them at:


Or, take a look through our blog to review industry insights, wins and all things Experimentation.