pay with Klarna
Payment options
Fast & Reliable
Detailed & Accurate
Useful & Valuable
Previous slide
Next slide

How to use Regex in Google Search Console

RegEx can be used in Google Search Console to filter and analyse website data. Knowing how to use it can help create reports and find additional insights.
How to use Regex in Google Search Console

A RegEx is a sequence of characters that we can use to search or manipulate text or data. Marketers can use these expressions to find and replace pieces of text, find a list of words or phrases in a document, or find URLs that contain a certain word.

 

RegEx (regular expressions) can be used in Google Search Console to filter and analyse website data. It is a really useful feature, and knowing how to use it can help you create reports in a more timely manner and find additional insights.

Using Regular Expressions in Google Search Console

The addition of RegEx in GSC allows users to utilise advanced filtering on Search Console data, which had only previously been possible through the API or manual manipulation of exported datasets.

 

Since RegEx is built into the interface, filters are applied to the entire dataset instead of only the first 1,000 lines of data we get in an export. This means we can get much more insight from the data that is already available to us, such as surfacing additional search queries and looking for opportunities that we may have otherwise missed.

 

RegEX also allows us to use positive and negative matching rules. So, for example, if we wanted to exclude brand searches from our queries, we can!

 

To use RegEx in Google Search Console, you can enter the regular expression in the filter box in the Performance report by using the appropriate syntax. Google provides a guide to the syntax and operators used in Regex in their documentation. It is important to use Regex carefully and test it thoroughly before applying it to your website data.

Benefits of Using Regular Expressions in Google Search Console

We have found several benefits to using RegEx in Google Search Console, all of which come back to the idea of helping us get better SEO insights.

 

You can gain deeper insights into your website’s performance in search results and identify opportunities for optimisation. It can help you to recognise patterns and trends that may not be immediately visible with simple searches.

Regex

You can also use RegEx to create customised data views that focus on explicit criteria, such as URLs containing a certain word or phrase or pages with a certain number of impressions. It’s also advantageous to filter out URLs containing parameters or tracking codes that are irrelevant to your analysis.

 

If you have certain criteria that you want your URLs to meet, or if you want to see URLs with Clicks only above a certain number, you can use RegEx to help you validate that data.

 

Most importantly, you can even begin to work more efficiently by automating data analysis tasks and enabling you to focus on the most important data or even excluding irrelevant pages or URLs from your reports.

 

By learning RegEx, you can become a more effective SEO professional and achieve better results for you and your client’s websites.

Examples of using Regex in Google Search Console

If you’ve made it this far in the article, you may be thinking this all sounds great, but you want some more tangible examples of how you can use regular expressions in GSC.

 

Here are some common ways you can use regular expressions:

 

Filtering URLs: You can use Regex to filter URLs containing a specific word or phrase. For example, if you want to filter all URLs that contain the word “blog”, you can use the following Regex code: .blog.

 

Excluding URLs: You can use Regex to exclude URLs that contain a word or phrase from your reports. For example, if you want to exclude all URLs that contain the word “service”, you can use the following Regex code: ^(?!.service).$

For this example relating to keywords, Choose New > Query > and then Custom (regex).

 

Filtering Queries: You can use Regex to filter queries that contain a specific word or phrase. For example, if you want to filter all queries that contain the word “how to”, you can use the following Regex code: .how to.

query regex

Some additional examples of RegEx use on GSc would be:


Filtering Countries: You can use RegEx to filter data by country. For example, if you want to filter data for all users in the United States, you can use the following Regex code: ^US$

 

Filtering Devices: You can use RegEx to filter data by device type. For example, if you want to filter data for all users on mobile and tablet devices, you can use the following Regex code: ^(mobile|tablet)$

Useful RegEx for Google Search Console

Here is a list of useful regular expressions we tried in Google Search Console:

 

.audit. – This formula will match any URL that contains the word “audit”.

 

^speed$ – This expression will match any URL that exactly matches the word “speed”.

 

^/category/.* – This will match any URL that starts with “/category/”.

 

^/[0-9]{4}/[0-9]{2}/[0-9]{2}/.* – This formula will match any URL that follows the format of a date-based URL, such as “/2022/01/01/post-name/”. This expression is especially useful for blogs built on WordPress.

 

^https://www.example.com/.* – This expression will match any URL that starts with “https://www.example.com/”.

 

^(?!.archive). – This will exclude any URL that contains the word “archive”.

 

^[A-Z]{2}$ – This formula will match any country code that consists of two uppercase letters, such as “US” or “CA”.

 

^(mobile|tablet)$ – This expression will match any device type that is either “mobile” or “tablet”.

 

([^” “]*\s){7,}? – This will show you all the queries with 8 or more words. This is great for finding long-tail keywords.

 

audit$ – This formula will return URLs with a similar ending. So, we could use this to find all URLs that end with “…-audit”.

 

.*(best|top|vs|review*).* – This expression is great for finding queries with commercial intent.

 

.*(buy|cheap|price|purchase|order).* – This is great for finding queries with transactional intent.

Quick Tips on Using Regular Expressions (RegEx) in Google Search Console

Test Your Regex: Always test your RegEx before applying it to your website data. Make sure you are confident your expression has returned accurate results before exporting your data.

 

Use Parentheses: Use parentheses to group parts of your RegEx together and make your RegEx easier to read.

 

Use Alternatives: Use the “|” symbol to create alternatives in your RegEx. For example, you can use “mobile|tablet” to match either “mobile” or “tablet” devices.

 

Be Specific: Use specific criteria in your RegEx to filter your data more specifically. For example, instead of using “.shop.” to match any URL that contains the word “shop”, use “\bshop\b” to match only URLs that contain the word “shop” as a separate word.

 

Use Anchors: Use the “^” and “$” symbols to anchor your Regex to the beginning and end of a string, respectively. This can help you to avoid matching unintended URLs.

 

Be Careful with Wildcards: Use wildcards, such as “.*” and “.+”, sparingly and carefully. These can match unintended URLs and lead to inaccurate data analysis.

 

By following these tips, you can use regular expressions in Google Search Console to create elaborate filters and gain deeper insights into your website’s performance in organic search results.

Picture of Nikki Halliwell

Nikki Halliwell

Based in Manchester, UK, Nikki is a freelance Technical SEO Consultant. She has worked at several agencies and in-house and has worked across the health, hospitality and fashion industries and more. Nikki enjoys working with eCommerce websites and beyond to ensure that websites are easy to find, load quickly and work efficiently. 
Search