Using Regular Expressions in Google Search Console

Written by Tiago Silva. Updated on 01, September 2023

Using RegEx in Google Search Console makes life better for marketers and SEOs to build advanced filters across the query and URL data available in the tool.

Previously, you could do basic filtering on Google Search Console data, such as equals, contains, and not contains. However, these types of filters have their limitations.

RegEx allows you to do complex pattern matching on your site's query and URL data to filter multiple values simultaneously. This makes it easier and quicker to uncover valuable queries that you can use to optimise existing content and create new pages on your site.

That's why RegEx is a big deal, and in this article, you will discover more about what RegEx is and why it can help you find post-purchase searches from customers or get more content ideas.

Don't sleep on RegEx. It has a bit of a steep learning curve, but it can save you vast amounts of time when analysing your website query data. There are also a lot of examples to get you started, which we cover soon.

This article is part of our Google Search Console tutorials and training section. Make sure to check the others out here.

What are Regular Expressions?

Regular expressions, also known as RegEx, were invented by Stephen Cole Kleene in the 1950s.

A RegEx is a sequence of characters used for searching or manipulating text. These expressions use metacharacters and literal characters.

Metacharacters combine strings that give special meaning to perform searches. For example, \s (lowercase S) will match whitespace, and \S (uppercase S) will match everything that isn't whitespace.

A literal character is a normal one. This means a literal character doesn't have a secondary meaning. For example, in the expression ".*Tesla.*", we are searching for strings that contain 'Tesla', while the dots and asterisks are metacharacters.

Please note the difference between lowercase and uppercase in the example above.

Interestingly, all the query data stored in Google Search Console is lowercase, so you don't need to worry about case sensitivity with your RegEx queries.

These expressions are used by search engines (like Google), text editors (like VS Code or Notepad), and word processors (like Microsoft Word).

Some practical examples of RegEx are:

  • Find and replace text;
  • Use a list of words or expressions and find them in a document;
  • Find URLs that contain a specific comment (for example, product names).

A RegEx expression can look like this: (?i)^(Google Search Console|Search Console| GSC).

This expression is a case-insensitive search for "Google Search Console", "Search Console", and "GSC". This means "search console" and "gsc" are possible results.

Note: The pipe character ("|") means or.

What are the Benefits of Using ReGex in Google Search Console?

As we have seen, RegEx is used for searching data stored as text, and as part of our job as SEOs, we deal with lots of query and URL data.

Until now, if we have wanted to do any kind of advanced filtering on Search Console data, we have had to export the data to a spreadsheet or get a programmer to interface via the Search Console API. Any export was limited as Search Console only exported the first 1,000 rows of data for you!

With RegEx support now directly within the Search Console user interface, we can run advanced filters and queries directly within the tool. As this is now within Search Console, the filters are run over the entire dataset of questions or URLs available, which can often run into tens of thousands.

This allows you to see a much wider variety of queries your site appears in Google for and an opportunity to target those queries with specific content upgrades or new pages.

Here are some other benefits of using RegEx in Google Search Console:

  1. Custom Analysis: RegEx allows you to create custom filters and segments that wouldn't be possible using the standard query filters provided by Google Search Console. This will enable you better to understand your website's performance and user behaviour.
  2. Identifying Trends: Using RegEx, you can better identify trends in user behaviour that might not be so clear through simple query filtering. This can help you discover emerging search queries or changes in user intent.
  3. Data Cleanup: Regular expressions are beneficial for data cleanup. You can use them to consolidate variations of keywords into a single group, making your data analysis more accurate.
  4. Complex Queries: If you need to analyse specific queries or keywords with a complex structure, RegEx provides the flexibility to define intricate patterns that match those queries.
  5. Segmentation: Regular expressions allow you to segment your data based on different parameters. For example, you can segment by query, user locations, or device types. This will allow you to understand better how different user groups interact with your website.
  6. Competitor Analysis: By using RegEx to filter queries related to your competitors, you can gain a tremendous amount of insight into how you compare in terms of search visibility and performance for specific keywords or topics.

How to Use ReGex in Google Search Console?

This section will guide you to using regular expressions within your Google Search Console dashboard.

GSC allows positive and negative matching RegExes. This is useful for excluding search queries from the stats, like removing brand searches to understand better the pages people find on your site.

Enter Google Search Console

First off, head to Google Search Console and log in to your account. You will then be greeted with your dashboard, looking like this:

Google Search Console overview page.

Find your Search Results Performance Report.

The next step will be to head into your Performance Report, ensuring you click on your "search results" performance report rather than your "discover" performance report.

Click on the "Search results" link on the left-hand side of the screen, located under the "Performance" tab:

Google Search Console Search Results performance tab.

Click on "+ New" in Filter Options.

Once you are on your search results performance report, you need to click on the "+ New" query option, we have highlighted this for you in the screenshot below:

Creating a new filter in Google Search Console.

Add a New "Query" or "Page" Filter to Access ReGex Options

When adding your new filter, select the "Query" or "Page" option:

Google Search Console filters can be created for Queries or Pages.

Now, click on the drop down option for your filter, this will either be labelled "queries containing" or "URLs containing" depending on whether you selected a query filter or page filter.

Once you have clicked the drop down option, select the "Custom (regex)" option.

Creating a custom regex filter for pages in Google Search Console.

Write your ReGex

Now, it's time to write or paste your RegEx into Google Search Console.

Text area to write custom regex in Google Search Console.

Attention: The only filters that support RegEx are "Query" and "Page".

Why use RegEx Instead of Other Filters?

Now you might be asking yourself when to use the default filter in GSC or RegEx.

Well, that's a great question.

Google Search Console filtering options are pretty basic compared to RegEx. For example, you can only filter 1 URL, 1 keyword, or 1 country at a time with the default filters. This is a severe limitation of the searches you can make.

That's where RegEx comes to the rescue. Especially as you can get creative and write expressions for your personal use case.

Sidenote: It's also worth mentioning that searching for special characters like foreign characters in URLs isn't supported with RegEx in GSC.

What Useful Data can ReGex Provide?

RegEx is a versatile tool within Google Search Console, enabling you to extract and manipulate specific data from your search performance reports.

Once application involves URL analysis, where RegEx helps you to filter URLs based on patterns like keywords or parameters. This helps you focus your analysis on particular sections of your website, rather than your website as a whole.

Another use is gaining keyword insights. By applying RegEx to search query data (where available), you can detect trends or patterns in user search terms. This helps you understand user intent and identify popular search queries, which you can then sort based on topics.

RegEx can also plat a vital role in error detection. It will assist you in finding URLs containing specific error codes, such as 404 or 500 errors. This functionality helps you be proactive in finding and fixing broken links or server errors. Doing this will help improve your user experience and, potentially, your search rankings.

SEOTesting's "ReGex Cheat Sheet"

The use cases for RegExes inside Search Console are ever-growing, as SEOs keep finding more valuable expressions. You'll find a list of helpful filters below.

Find longtail keyword questions with RegEx

There are several ways to find longtail keywords with RegEx. Here you'll read about 3 different examples.

The first one was shared in the SEO Notebook newsletter by Steve Toth.

The RegEx is: ([^" "]*\s){7,}?

This expression will show you all the queries with 8 or more words.

To get information about shorter queries, change the number "7". For example, to get 5 words, change "7" into a "4". Basically, put the number of words you want to find minus 1 into the expression.

Finding long-tail keywords in Google Search Console using regex.

Find pages ending in a specific slug

Hannes-Jeremia shared how to find URLs with a similar ending on Twitter. This simple tip is helpful for large websites.

The RegEx you should use is: word$

In this case, replace "word" with the keyword you are looking for in the URLs. Then you only need to put finish the expression with a dollar sign ($).

Let's see an example for the word holidays.

I'll use holidays$ as a RegEx in GSC. The results are the following:

Regex allows finding pages in a specific URL slug.

Brand vs Non-Brand traffic

Jean-Cristophe-Chouinard has an extensive list of RegEx use cases for GSC.

One of the most significant examples in that list is comparing brand versus non-brand organic traffic.

This filter will give you an overview of visitors to the website that already knows your company versus potential first-time visitors.

To do it, use the comparison tab and this expression: .*domainName* as you can see on the screenshot below.

Regex to compare brand vs non-brand queries.

Find after purchase queries

RegEx can help you find what post-purchase queries your site is currently ranking. This is useful for knowing potential problems with your products and creating content around these searches.

The tip was shared by Christopher on Twitter.

And looking at the tweet comments, I'll change his expression to accommodate Timothée suggestion that gets even more queries from Google Search Console.

The RegEx is: \b(clean|broken|wash off|shattered|polish|problem|treat|doesn't work|replace|doesn't start|scratch|repair|manual|fix|protect|renew|coverage|warranty)[" "]

Regex to find after purchase queries.

Understand User Intent

Another use for regular expressions is understanding the user intent.

Usually, these types of searches are divided into:

  • Informational;
  • Navigational;
  • Commercial;
  • Transactional.

This tip is a combination from Jean-Cristophe-Chouinard, Steve Toth, and Michael Martinez.

For quite some time, Google has understood the user's search intent. Thus, filtering keywords similarly to what people search is good for producing or improving content related to those searches.

You can paste the following expressions into GSC to find queries based on user intent.

Informational

RegEx to use: who|what|where|when|why|how|was|did|do|is|are|aren't|won't|does|if|can|could|should|would|won't|were|weren't|shouldn't|couldn't|cannot|can't|didn't|did not|does|doesn't|wouldn't

Navigational

Example of Regex to use: .*brand.*

Note: If your company is called Tesla, replace "brand" with "Tesla" to perform the search.

Another potential use for this brand could be to check if you are ranking for queries, including a competitor name. It's popular to build pages targeting "versus" and "alternative to", so this is an excellent expression to check those rankings.

Commercial

RegEx to use: .*(best|top|vs|review*).*

Transactional

RegEx to use: .*(buy|cheap|price|purchase|order).*

Where to Learn ReGex Queries

To learn RegEx queries and better use Google Search Console, you can explore several very effective approaches:

Try starting with online resources and tutorials. There are a whole host of websites (like RegexLearn or RegexOne), blog posts and videos online that will offer interactive tutorials and explanations, tailored to Google Search Console usage. These resources are very effective at helping you grasp the fundamentals of regular expressions in a practical context.

You can also refer to Google's official documentation, Navigate to the Google Search Console Help Center and, from there, you can search for guides and articles focused on using regular expressions within the platform. Google official documentation will provide insights and examples, specifically relevant to GSC.

If you have the funds available, you can also look to enroll in online courses. Platforms like Udemy, Coursera and LinkedIn Learning offer dedicated courses on regular expressions. You can refine your search and find courses that address using RegEx within Google Search Console, or other SEO-related contexts. These courses will often feature practical exercises and real-world examples to help you learn.

One of my favourite methods, for all things learning SEO is engaging with SEO and webmaster forums, like the communities found on Stack Overflow or Reddit. You can use these platforms to ask questions and learn from professionals who have used RegEx in Google Search Console regularly.

Remember that proficiency with RegEx comes with practise and gradual learning. Approach your regular expressions systematically, starting with foundational concepts. Then progressively tackle more intricate and complex patterns. The complexity of RegEx requires patience, so take your time to comprehend and practice each concept thoroughly.

Final Thoughts

RegEx is a powerful instrument for any marketer to create advanced filters when dealing with data, including Google Search Console.

It's one of the best ways to filter and find unobvious information to make performance reports in a short period.

As you saw, many generous people share their RegExes and use cases online that can help with your job and learn RegEx faster.

And speaking of learning RegEx, Regex101.com is one of the most mentioned resources.

Also, it's worth mentioning that JC Chouinard keeps adding more use cases to this list, so it's helpful to bookmark the page and visit it regularly.

SEOTesting can help automate your use of RegEx within Google Search Console, we have a huge range of reports that fill in the RegEx for you, allowing you to speed up your workflow and find new ways to optimise your site for more organic traffic.

We are currently offering a 14-day free trial, with no credit card required to sign up.