Using RegEx for targeting your surveys
Regular Expressions allow people to search for certain strings of characters and pieces of information in a line of code. With Survicate you can use them to target specific sets of pages without applying a number of different rules.
Most widely used characters
. The Dot is used when you want any character to match. For example, if you have .a regex it will match all the bold letters from the following string (car, leaf, spear).
* The Star symbol matches zero or more of preceding character (ex. a*r regex matches the following: car aaaaar lure).
+ The Plus is similar to a star, but matches one or more character. It means that in the following string regex a+r will match: car aaaaar lure.
.* Dot-star matches any string of characters. For instance, if you want to target all visitors that have used your coupon, you can write a piece of Regex
and regardless of coupon number (ex. coupon=132, coupon=9074217, coupon=4238) it will match.
\ The Backslash lets you escape the special characters. For example, if you need to escape the dots function: solutions\.com means solutions -dot- com, not solutions -any character- com. You will also need to escape slashes (/) so that solutions.com/industry/security in RegEx will like this:
? The Question mark is for marking preceding characters as optional, for example if you want to match subdomain.solutions.com as well as solutions.com you should write your RegEx like this:
So the subdomain. will be optional.
( ) The Brackets are for grouping specific items together, as shown in the previous example where the whole string in brackets (subdomain\.) placed before the ? was optional.
| The Vertical Bar (or Pipe symbol) allows you to match more than one element, for instance, the RegEx
Will match either solutions.com/industry/security or solutions.com/industry/it. ❗️Remember to put the elements you want to match in brackets!
Targeting only those pages that have a specific string in their URL
If you want to target every page that contains a specific word, use (?=stringyouwantinURL) around the word, for instance, the word feature in the code
but won't match URLs like:
Excluding the pages that don't have a specific string in their URL
If you want to exclude every page that contains a specific word, use (?!stringyoudontwantinURL) around the word, for instance the word feature in the code
but won't match: