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:

www.examplewebsite/product/123456

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:

www.examplewebsite/product/.*

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

More from the glossary

Server-side Testing

Server-side Testing Expand your possibilities with Server-side testing. What is Server-side Testing? On a basic level, when delivering A/B or

Read More »

Onsite Retargeting

Onsite Retargeting Increase Cross-sell and Up-sell Opportunities Unlike offsite retargeting (pay-per-click advertising, for example), retargeting a consumer while engaged on

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: https://help.webtrends-optimize.com/optimize/training-videos/

Blog

Or, take a look through our blog to review industry insights, wins and all things Experimentation. https://www.webtrends-optimize.com/blog/