Search results for "{{ search.query }}"

No results found for "{{search.query}}". 
View All Results

Using Regular Expressions

How-to article

What are Regular Expressions?

A Regular Expression (regex or regexp for short) is a special text string for describing a search pattern. You can think of regular expressions as wildcards on steroids.

It is unlimited what a regular expression can include and/or exclude. Here we will be listing the most popular user-requested examples:

Regex Tester

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

Targeting multiple pages.

Wildcard examples: (where * can be anything)





3:<user_id>/profile/ (numeric user_id)


Wildcard excluding a certain pattern:
Target all pages which match the pattern but do not include the word "article" or "post":*/subpage/


Excluding certain words or patterns in a URL:

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


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


Multiple pages which don't follow any pattern:
Target these three pages:


Pages case insensitive:
Target the following page irrelevant of case: For example, will also match.


Targeting pages which URL can end with or without a trailing slash.

Depending on how your server is set up, the different pages on your site can be referenced in either one of these cases or both:


The difference is the trailing / at the end. In most cases, this is usually the same page showing the same content, however since this is not necessarily the case, Hotjar doesn't assume it is since it could potentially skew results such as Heatmaps.

This is usually a problem when you set up a Heatmap using the following URL:

But you site or external sites are linking to this version of the URL:

How to target both URLs using a Regular Expression

In order to target both the examples shown above, this simple Regular Expression can help you do that:


This regular expression will match visits if the URL ends with '/products' OR '/products/'.

If the URL you intend to target might contain a query string or fragment you'll need to use a slightly more complex expression:


This regular expression will match visits if the URL ends with '/products' OR '/products/', as well as '/products?name=value' and '/products/#fragment'.

If you are setting up a Heatmap, you will notice Hotjar asks you for a 'Screenshot Page URL'. Simply set the screenshot page to one of the variations, such as ""

Targeting multiple IPs (used in IP Blocking).

IP Range Regular Expression Builder

We highly recommend using this tool to generate IP ranges in regex format:

The examples below are just examples using local IPs. When using IP Blocking you should use public IPs.

Simple IP match (single IP): or 192\.168\.0\.1

Both would work since in regex, the "." character means "any character".

IP Ranges -

192\.168\.0\.(1[4-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]|6[0-2]) -


CIDR notation IPs:



For CIDR notation IPs, you can use this CIDR to regex converter:

Different IPs

Target all these IPs:


Using Regular Expressions

How-to article