Favorite Feature: Regular Expressions with Capture Group

By Ruby Brown

December 9, 2019


SiteSpect’s Customer Success team knows the SiteSpect solutions better than anyone. From building campaigns to advising on optimization strategy, they use every feature SiteSpect has to offer. In this series we will interview the members on the Customer Success team and highlight some of their favorite features, why they love them and why they should be your favorites.

Customer Success Team Member: Dave Gullo, Technical Account Manager

Favorite Feature: Using Regular Expressions with the use of capture groups in Campaign and Global Variations, Metrics, and Audiences.

How it works: Triggers support the use of regular expressions (regex). But using regex in the find section of a Find and Replace variation also supports the use of capture groups. In the replace section the captured content is available in numbered capture group variables.

If you have the following HTML:

<div class=”parent”>
<div>Section 1: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>
<div>Section 2: Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</div>
<div>Section 3: Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>

And you wanted to switch the position of the first and third div sections. The following Find could look like:

and the Replace would be:

This is great because using capture groups to capture content in a page source with regex pattern matching enables reordering dynamic source content in flexible and ways which enables easy reuse for page families, for example.

It’s a powerful and elegant tool that can enable comprehensive source changes, save time, and reduce complexity or changes.

Examples: Many common use cases involve reworking of page families such as home pages, product listing pages, detail pages, other pages, and even JSON.

The reverse proxy architecture that SiteSpect uses enables nearly unlimited power to the page source where the changes happen before the response is received by the end user.

To learn more about SiteSpect, visit our website.


Ruby Brown

Ruby Brown

Suggested Posts

Subscribe to our blog: