Back to The Lab

A guide to Regex in Google Search Console

Regular expressions, or regex, are powerful tools to find specific patterns in text, to search and manipulate data more efficiently. Regex works through a syntax to define search patterns, that’s very useful for SEOs who need to segment big data based on specific search behaviors or keywords.

Need to know the what and the how? Strap in, and let's go! 🚀

What is Custom Regex in Google Search Console?

In Google Search Console, regex filters give SEOs more control over data by finding patterns that simple filters can’t reach. They allow you to segment data like brand vs. non-brand searches, long-tail queries, or intent-based groupings, offering a way to dive deeper into user behaviours and refine SEO strategy.

Custom regex filters also let SEOs uncover specific trends within GSC itself, without needing to export data or use other tools. This makes it easier to spot valuable patterns directly in GSC, saving time and revealing insights that can sharpen SEO decisions, from content optimisation to keyword targeting and competitor analysis.

Why should we Use Regex in Google Search Console?

Regex in Google Search Console opens up a more flexible way to filter and interpret search data by finding specific patterns in user queries and page URLs. This added precision is great for SEOs who want to go beyond basic filtering options and dig deeper into user behaviour. Here’s why regex can be a game-changer:

  1. Pinpointing data patterns: regex helps isolate patterns in queries that would be hard to find with standard filters. For example, you can use regex to locate queries with specific phrases or character lengths, which is helpful for understanding how users search for your content.

  2. Segmenting user intent: divide queries by intent, like informational (e.g., queries starting with "how," "why"), transactional (e.g., "buy," "price"), or navigational (e.g., branded terms). This way, you can get a clearer picture of why users land on your site, helping to tailor content and campaigns to different user needs.

  3. Filtering for branded vs. non-branded terms: you can quickly filter branded queries to see how much of your traffic comes from brand-aware users versus those who are discovering your site for the first time. This is especially useful for tracking brand growth and the impact of brand-focused marketing.

  4. Removing irrelevant data: clean up your data by filtering out irrelevant terms or specific patterns that don’t contribute much to SEO insights. For example, if certain keywords or phrases appear frequently but don’t add value, regex can filter them out, leaving a more refined dataset.

  5. Identifying complex search patterns: regex is invaluable for spotting trends in search terms, like finding queries with high character counts or specific word structures, which can highlight emerging interests or questions among users.

Setting Up Regex Filters in Google Search Console

Setting up regex in Google Search Console is simple and can make filtering data much more powerful. Here’s a step-by-step guide:

access performance report

  1. Access Performance Report: Open Google Search Console and go to the Performance report.

add new filter

  1. Add a New Filter: Click the “+ Add Filter” button to add a filter. You can choose to filter either Query or Page data.

choose regex filter

  1. Choose Regex Option: Select “Custom (regex)” in the filter options.

enter regex pattern

  1. Enter Your Regex Pattern: Type in the regex pattern you want to use, whether it’s for excluding branded terms, filtering long-tail queries, or anything else.

Hit apply to see the filtered data, and start analysing based on your custom criteria. With these filters in place, you’re ready to dive deeper into understanding specific trends in search traffic, segregating brand vs. non-brand terms, and pinpointing long-tail queries—all directly within Google Search Console. Now, let’s look at some of the most common use cases for regex in SEO to help you get the most out of these filters.

Best Regex to Use in Google Search Console

Below is a table of some of the best regex patterns for common SEO scenarios. This provides you with a quick reference guide for various needs, from filtering branded terms to spotting long-tail queries.

To get the most out of these filters, it’s a good idea to test your regex patterns first. This helps avoid any accidental filtering out of important data. You can use tools like regex101 to validate your expressions before applying them in GSC.

use case

regex pattern

pattern explanation

example query/url

GSC application

expected outcome

Filter Branded Terms

brandname|brand name

Finds any query containing the word “brandname” or "brand name"

brandname reviews, buy brand name

Query Filter (use "Matches regex")

Isolates all brand-related search terms

Exclude Branded Terms

brandname|brand name

Excludes queries containing the word “brandname” or "brand name"

compare products, top laptops

Query Filter (use “Doesn’t match regex”)

Excludes brand-related queries

Exact Brand Terms Only

^(brandname|brand name)$

Only queries that are exactly “brandname” or "brand name"

brandname, brand name

Query Filter (use "Matches regex")

Isolates all exact brand searches

Match Exact Phrase Only

^exact phrase$

Matches only the specified exact phrase

laptops

Query Filter (use "Matches regex")

Filters data by exact phrase match

Match Multiple Exact Phrases

^(exact phrase|another exact phrase|one more exact phrase)$

Matches only the specified exact phrases

laptops, lap-tops, lap tops

Query Filter (use "Matches regex")

Filters data by exact phrases

Identify Long Queries by Characters

.{20,}

Matches queries with 20 or more characters

where to buy high-quality laptops

Query Filter (use "Matches regex")

Segments longer queries, often more specific

Identify Long Queries by Words

(\w+\s){3,}

Matches queries with 4 or more words

find best travel laptop under budget

Query Filter (use "Matches regex")

Isolates long-tail, multi-word queries

Filter by Specific Path

/products/.*

Matches URLs in the /products/ directory

/products/item123

Page Filter

Isolates traffic to a specific site section

Match Secure URLs (HTTPS)

https://

Matches URLs that start with HTTPS

https://example.com/page

Page Filter

Focuses on secure (HTTPS) URLs

Exclude URLs Ending with Slash

^.*[^\/]$

Finds URLs that don’t end with a trailing slash

https://example.com/product

Page Filter

Focuses on URLs without trailing slashes

Filter Local Searches

^(near me|in\s+\w+)

Captures queries starting with "near me" or "in [location]

dentist near me, car rentals in London

Query Filter (use "Matches regex")

Isolate queries indicating local search intent

Isolate Numeric Queries

^[0-9]+$

Matches queries containing only numeric characters (useful for filtering out year, model, or code searches)

2024, 12345

Query Filter (use "Matches regex")

Isolates numeric-only queries, allowing for focused analysis on searches that contain only numbers.

Customising regex filters in GSC gives you so much more to work with as an SEO. Whether it’s isolating branded terms, filtering question based queries or local search intent, regex is a super flexible way to view organic search data. With this level of control, you can directly improve your SEO by targeting user intent and finding patterns in how people interact with your site.

google search regex meme

So, there you have it! Bookmark this guide for easy reference, and feel free to share it with anyone who could benefit from utilising regex in Google Search Console.

If all this regex talk feels a bit overwhelming, feel free to reach out to us. Our SEO team loves digging into data and fluent in regex, so you’ll be in good hands!

Useful Online Regex Testing Tools

regex101: A tool for testing and debugging regex patterns.

Regexr: A tool for building and refining regex expressions with a regex syntax library.