Using RegEx In Insightech (With Examples)

Using Regular Expressions In Filters & Segments

Want to use RegEx in Insightech, but you're not sure where to begin? Here is a run-down to help you get started.

What are Regular Expressions?

A Regular Expression, REGEX or REGEXP for short, is a special text string for describing a search pattern.

Regex Tester

This regex tester can help you build regular expressions. Make sure 'javascript' is selected in the menu on the left.

Examples Of Targets

1. Wildcards (where * can be anything)

Target: www.example.com/pages/*

Regex Example:

^(http|https):\/\/www.example.com\/pages\/.*$

Target: www.example.com/pages/*/article/

Regex Example:

^(http|https):\/\/www.example.com\/pages\/[^\/]+\/article\/$

Target: www.example.com/user/<user_id>/profile/(numeric user_id)

Regex Example:

^(http|https):\/\/www.example.com\/user\/[0-9]+\/profile\/$

2. Wildcards excluding a certain pattern

Target: All pages which match the pattern but do not include the word "article" or "post" www.example.com/pages/*/subpage/

Regex Example:

^(http|https):\/\/www.example.com\/pages\/(?!article|post)[^\/]+\/subpage\/$

3. Excluding certain words or patterns in a URL

Target: All pages which do not include "/somepage" and "/someotherpage"

Regex Example:

^((?!\/somepage|\/someotherpage).)*$

Target: Pages which include the word "page" and do not include "somepage":

Regex Example:

(?=.*page.*)(?!.*otherpage).*

4. Multiple pages which don't follow any pattern

Target these three pages:

  • www.example.com/pages/article-one/details/
  • www.example.com/pages/some-random-word/details/
  • www.example.com/pages/another-post/details/

Regex Example:

^(http|https):\/\/www.example.com\/pages\/(article-one|some-random-word|another-post)\/details\/$


How did we do?


Powered by HelpDocs

Powered by HelpDocs