Regular Expressions (Regex) Basics

A regular expression (regex or regexp) is a group of characters that you can use to match complex patterns in URLs. Within the Monetate platform, you can use regular expressions for pattern-matching or search-and-replace functions in Full-Page Test experiences, within content masking rules, within the Conditions tab of the Builder tools, or in the optional inputs section of an action to specify which page an action should run.

Monetate uses Perl-style regular expressions, which aren't case-sensitive. The following parameters are recognized in regular expressions:

  • Modifiers
  • Brackets
  • Metacharacters
  • Quantifiers

For more information about creating regular expressions, refer to W3Schools' JavaScript RegExp Reference, or use the Regular Expression Editor and Debugger tool by Regex101.

In Action Builder

When you create an action in Action Builder, you input regular expressions on the Conditions tab by selecting URL matches regular expression from the URL category in ADD CONDITION.

Callout of the 'URL matches regular expression' option in the URL category of the ADD CONDITION selector on the Conditions tab of Action Builder

You can use the following regular expression on the to specify a content mask that only appears on URLs that end with webpage.aspx:

^https.+webpage.aspx$

An action condition based on 'URL matches regular expression' with the value '^https.+webpage.aspx$' on the Conditions tab of Action Builder

In Full-Page Test Experiences

For a Full-Page Test experience, you can use the following expressions:

  • Location to test^https.+webpage.aspx$
  • Replacement pagehttps://example.com/new.aspx

At the Experience Level

You can apply an action condition with a regular expression for an action at the experience level.

Animated demonstration of a user adding an action condition that is based on a URL with a regular expression

Here's an example of a regular expression used in an action condition added at the experience level:

^https.+webpage.aspx$

This regex would match these URLs:

  • https://example.com/webpage.aspx
  • https://example.com/webpage.ASPX

It wouldn't match these URLs:

  • https://example.com/webpage.asp
  • http://example.com/webpage.aspx

In Target Builder

On the Conditions tab in Target Builder, you can input regular expressions that act as a filter for when the target should be evaluated.

Callout of the options in the the Operator selector on the Conditions tab in Target Builder