REGEX adds muscle to our segmentation exercise – offers limitless opportunities for fine-tuning and filtering if done right. In this post, we will glance through some of the more practical examples of REGEX.


Why do we use REGEX?

  • It assists us in creating precise filters
  • REGEX helps us to create Goals that involve multiple goal pages
  • The use of REGEX certainly fine tunes our funnel steps so that we can get exactly what we are aiming for



10 practical uses of REGEX


[1] Product list profile: If you are an ecommerce product manager and you need a special profile of visits for only a select group of products – leatherbags671 through leatherbags679. The filter would look like: Include à Request URL à Filter Pattern = leatherbags67[1-9] ß REGEX



[2] We have sales page based on region: If you are interested in having a filter only for 2 regions –



The REGEX that will be used in the Filter would be: Product (1 | 2) /Sales



[3] Creating a very specific list of data for inclusion or exclusion: Braces repeat the last “piece” of information a specific number of times. When there are two numbers in the braces, such as {a,b} , it means, repeat the last “item” at least a times and no more than b times . When there is only one number in the braces, such as {b}, it means, repeat the last item exactly b times.


Example: Many organizations have a block of numbers that needs to be excluded for testing purposes. Let’s say their IP addresses range from through – In this case our regular expressions would be:




[4] Capture all in between: There are two Regular Expressions that, when put together, mean “capture all.” They are a dot followed by a star, like this: /datafolder/.*index\.php In this example, the Regular Expression will match to everything that starts with datafolder/ and ends with index.php



[5] Misspellings: Misspellings are major reporting pain for most of us. A very common example of misspelled keyword search is: colour, color – To account for all the variance, we need to use the following REGEX: colo[u]*r

Other misspelling examples:


  • Voda(ph|f)one
  • Ste(ph|v|f)en


[6] Grouping file patterns: If we want to allow only a limited list of file extensions, the following REGEX will help: \.(pdf|doc|ppt)

[7] Matching URLs listed in your content: The following are examples to consider when matching


  • URLs listed in your Content / Top Content reports: \?(id|pid)=[^&]* à This matches the filename followed by the first query parameter and its value if its name is equal to id or pid. If you have a report with URIs of the following form, this regex will match the two URIs highlighted:




[8] Matching all suffixes in your list:

  • if you need to match all of the following: index.html, index.htm, index.php, index.aspx, index.py, index.cgi, the following REGEX can be utilized: index\.(h|p|a|c)+.+


[9] Carat as a negative grouping indicator: Example of carat as a negative grouping indicator:


  • Matches the following examples: 11, 42, 1,000,000
  • Matches all except 0, 1, 2, 3, 4, 5, 6, 7, 8 or 9



[10] Selective URL matching: If you want to match only the Products Page, Order page and Checkout page, the following REGEX will take care of this:

^(/|/Product/|/Order/Check-out)$ à What this regex says is, match any page that starts (^) and ends with ($) “/” OR “/products/” OR “/order/” OR “/checkout/”: