Regular expressions (regex) are a pattern-matching syntax you can use to search for complex strings. Google's Search Console (GSC) offers the option to use regex to filter and sort through search queries and page performance data.

You can optimize your site performance by analyzing search data using crafted regex filters.

The Benefits of Using Regex in Google Search Console

Regex Results Compare Option in Google Search Console Screenshot

Regex let you read and analyze data without relying on the Google Analytics web application or other external tools. Here are the many ways you can use regex to optimize site performance:

  • Create queries to filter pages with the least CTR and determine how to optimize them to perform better.
  • Gain insights into the kind of queries that trigger your pages, like how-to questions, misspelled words, etc. Optimize your site to cater to these queries.
  • Based on query intent, businesses can fill in knowledge and information gaps about their products and services.
  • Get as granular as you want with regex targeting specific products or pages. For example, understand the data and metrics of a limited edition offer within a particular duration.
  • Instant results based on previous GSC data, no need to set up filters and wait for goals.
  • Compare and contrast custom results for different data sets to gain further insights into your site's search performance.

Free Resources to Learn Regex

RegexLearn SEO Course Page Screenshot

Regex is easy to learn as its syntax is pretty straightforward. You can use the following resources to get a good understanding of the syntax and its application in various programming languages:

  • RegexOne: An interactive regex learning course simplified for non-technical users.
  • A GitHub repository, Learn Regex the Easy Way: Comprehensive regex text course with examples, tests, and translations available in various languages.
  • Our own article, The Beginner's Guide to Regular Expressions With Python: Quick guide to regex syntax supported by Python.
  • RegexLearn’s Regex for SEO: An interactive open source platform to learn regex for SEO.

Follow the #performanceregex hashtag on Twitter to learn about new regex ideas and queries for GSC.

How to Use Regex Filters in Google Search Console

Here's a step-by-step guide on how to use regex filters in Google's Search Console:

Step 1: Log in to Google's Search Console

You need admin access to your website's GSC account to use regex once you log in.

Google Search Console Login Page Screenshot

Step 2: Click on Performance in the Left-Hand Menu

Select the search property you want to view from the drop-down menu on the left-hand side. Then click on Performance to bring up search query data you can manipulate using regex.

Performance Tag in Google Search Console Screenshot

Step 3: Click on +New in the Filters Options

Click on +New in the filters' menu on the top of the page to bring up the Query and Page options.

New Filter Option for RegEx in Google Search Console Screenshot

Step 4: Click on Query or Page to Access Custom (regex)

When you click on the +New filter, you get four options. You can choose either the Query or the Page option to use regex in GSC.

Click on the Queries Containing drop-down menu to access the Custom (regex) option in the dialogue box with Filter and Compare tabs.

Step 5: Input the Regex in the Custom (regex) Field

Once you click on Custom(regex), you'll get a blank field to input your regex. Enter your regex here and click on Apply to see the custom results.

Custom RegEx Query Input in Google Search Console Screenshot

You can either match the results containing the regex string or filter them out using the Doesn't match regex option.

Google Search Console has a 4,096 character limit for regex strings.

Step 6: Export Regex Data

Click on the Export option in the top right corner to export the data to a spreadsheet or CSV file to manipulate it further.

Export Regex Data from Google Search Console Screenshot

4 Regex Examples You Can Use to Make the Most of Search Console Data

Regex queries will only work if your website has considerable search impressions to glean data from. Here are a few commonly used regular expressions to manipulate website data.

1. Regex for Questions in Search Queries

        ^who|^what|^where|^why|^when|^how|^will|^is|^was|^are|^do|^did|^does|^can|^if
    

This regex string brings up all the question-related search queries that your website showed up for. Add more question modifiers like should, would, won't, aren't, etc., to the query to bring up more results.

Question related queries results in Google Search Console Screenshot

Use the resulting data to create short posts catering to Google's featured snippets section, long-form blog posts answering queries with sparse results, understand user intent in clicking on your website, and get inspiration for content ideas.

Sort by the number of clicks to find posts with low click-through rates to improve the content you deliver on these topics.

2. Regex to Find Long-Tail Keywords

        (\w*\W){5,}
    

This regex string brings up search queries with six or more words implying a proper sentence or question.

Regex Results for Long Tail Queries in Google Search Console Screenshot

This regex string brings up search queries with six or more words implying a proper sentence or question. You can change the number 5 to any other number to shorten or elongate the query string to find more long-tail keywords.

Use long-tail keywords with high volumes as H2s in blog posts to boost your website's search ranking.

3. Regex to Match Misspelled Keywords

        Example: Ell?i?(s|z)?(a|e)?(b|p)?eth?
    

This example query matches all misspellings and variations of the name Elizabeth. You can create similar regex to find brand-related information, like data on common brand names misspellings, keyword variations, etc.

Example Regex for Misspellings Screenshot via Regex101

A ? following a letter indicates the letter may or may not appear in the string. Use the or function | to include all possible combinations for commonly substituted vowels or consonants. Add (?-i) to your query if you want case-sensitive matches.

Prepend ^ to your query to match keywords that begin with your string, or append $ to match keywords that end with your regex string.

Use this helpful testing tool from regex101.com to check whether your regex query works as intended.

4. Regex to Analyze Subdirectory Search Data

        Example: example.com/.*/brand1
    

This example regex shows the performance of all URLs for a particular subdirectory, along with the data on search queries that triggered these results.

Regex to Filter Subdirectory Performance in Google Search Console Screenshot

Use this query format in conjunction with your URL structure to find data about sets of products, product categories, best-selling brands, and more.

Copy the URL for useful regex queries and save it to rerun with a single click.

Optimize Your Website Performance With Regex

You can use regex in GSC to analyze query-related data or page performance metrics to enhance your website's search performance. Once you've mastered the art of using regex, leverage it for other purposes like software testing, validating HTML forms, and more.