Search Console Regex Filters for Queries and Pages

The Performance report in Search Console can filter queries and page URLs with a regular expression. One filter can then catch every spelling of your brand, every question-style search, or every URL in a section of your site. This guide covers how the filter works, the rules Google applies, patterns that are worth saving, and why the totals sometimes look wrong.

This guide uses Search Console Help: Advanced filtering and comparison, Overview and basic setup and Troubleshooting data discrepancies; two Search Central blog posts, Improved data filtering and comparison (April 2021) and Search Console regex filters update and quick tips (June 2021); the RE2 syntax reference; and the Search Analytics query reference for the API. Quotes are from those pages.

What the regex filter does

Google added regex to the Performance report in April 2021. Before that, its blog post explains, you could filter queries and page URLs in three ways only: "containing a string, not containing a string, and exactly matching a string." That made it hard to handle "a query containing one out of a few optional strings." A regex filter handles that in one line. A negative option followed in June 2021: "the Performance report filter supports both matching and not matching regex filters."

The Help page puts it like this: regex search "enables you to filter for, or exclude, multiple queries or URLs that might contain significant differences or variable sections." It works on the Queries and Pages filters. The 2021 post adds that the comparison mode supports regex filters for queries and pages as well, so you can compare one pattern across two date ranges.

If you are new to the report itself, start with our Search Console guide for business owners, which covers properties, verification and what the Performance report shows.

Regex or a "containing" filter

FilterWhat it doesUse it when
Queries / URLs containingKeeps rows that include one string. "The match is not case-sensitive, but is otherwise exact, including any spaces."Everything you want shares one word or path
Queries / URLs not containingDrops rows that include that stringYou want to remove one word or path
Custom (regex), Matches regexKeeps rows that match the patternSeveral spellings, several words, or a variable part in the middle
Custom (regex), Doesn't match regexDrops rows that match the patternYou want to remove several variants at once

Google's Help page says the "containing" method is "useful when all items you want to find contain the identical substring." Anything more varied than that is a job for regex.

Adding a regex filter

  1. Open the Performance report for Search results and click + Add filter in the filters row.
  2. Choose Queries or Pages.
  3. Choose Custom (regex).
  4. Enter your regular expression.
  5. To see everything except what the pattern matches, choose Doesn't match regex. Otherwise leave the default, Matches regex.
  6. Click Apply.

You can stack filters: the Help page's example is adding "country='USA' AND device='Mobile'" while grouping by query. Click the x next to a filter to remove it; the search type and date filters cannot be removed. Clicking a row in the table also adds a filter for that row.

The rules Google applies

  • Syntax: "The RE2 syntax is used." RE2 is Google's regex library. Most everyday syntax works, but the RE2 reference marks lookaheads such as (?=re) and (?!re), lookbehinds and backreferences such as \1 as "NOT SUPPORTED". Patterns copied from other tools that rely on those will not work. To exclude something, use Doesn't match regex instead of a negative lookahead.
  • Partial matching: "Your regular expression can match anywhere in the target string unless you use ^ (start of string) or $ (end of string)." So seo also matches "seo agency near me" and a URL like /guides/small-business-seo-basics/.
  • Case: "Default regex matching is not case-sensitive." Put (?-i) at the start for case-sensitive matching; Google's example is that (?-i)AAA matches https://example.com/AAA but not https://example.com/aaa. This matters mostly for URLs, since queries are rarely typed in capitals on purpose.
  • Several values: the Help page says to "separate them with a vertical bar (|) and surround the whole expression with parentheses".
  • Page filters see the full URL: Google's own examples include https://, so a pattern for a section such as /guides/ matches anywhere in the address, and ^https://www\.example\.com/blog/ pins it to one host and folder.

A dot means "any single character" in regex. In a URL pattern, write \. when you mean a real dot; the RE2 reference lists \* as the way to match any punctuation character literally, and \Q...\E for a longer piece of literal text.

The characters you will use most

These are from Google's own table of common regular expressions, with its examples:

CharacterMeaningGoogle's example
.Any single character"m.n" matches "men" and "man" but not "meen"
[ ]Any one item inside the brackets"c[aie]t" matches "cat", "cit" and "cet"
*The preceding item zero or more times"fo*d" matches "fd", "fod" and "food"
+The preceding item one or more times"fo+d" matches "fod" and "food" but not "fd"
|OR"New York|San Francisco"
\d / \DA digit / a non-digit"\d\d\d abc" matches "123 abc"
\s / \SWhitespace / non-whitespace"1\s2\s3" matches "1 2 3"
^Start of the string"^example" matches "example" but not "an example"
(?-i)Case-sensitive from here on"(?-i)AAA" matches /AAA but not /aaa

Two more from the RE2 reference are handy: $ for the end of the string, and \b, a word boundary, so \bhow\b matches "how to" but not "showroom".

Patterns worth saving

Google's two blog posts give the use cases below. The patterns marked as ours are our suggestions, not Google's; adjust the words to your site.

Brand and its misspellings

Google's examples: for a company called Willow Tree, willow tree|wilow tree|willowtree|willowtee; for "cats and dogs", cats and dogs|cats & dogs|c&d. Run it as Matches regex to see branded searches, then switch to Doesn't match regex to see the searches that come from people who did not know your name yet. Google now also has an automatic branded queries filter on some properties; how it works and who gets it is in our Search Console Insights guide. The regex version works on any property, and you decide exactly what counts as the brand.

Question searches

Google's example is what|how|when|why, which it says "might show results that indicate your content should easily answer questions, maybe through an FAQ." Because matching is partial, that also catches "somehow" or "whatsapp". Our tighter version only looks at the first word: ^(what|how|why|when|where|who|which|can|does|is)\b

Buying intent

Google suggests looking at queries with transactional words such as buy|purchase|order, with or without them. For a service business, our version would be price|cost|quote|near me|hire|agency.

A section of the site

On the Pages filter, Google's example for a URL like example.com/[product]/[brand]/[size]/[color] is shoes/.*/green, where .* matches anything in between. Simpler versions: /blog/ for one folder, or /(services|pricing)/ for two. Then switch to the Queries tab to see which searches lead into that section.

Long queries

Ours: ^\S+(\s\S+){4,}$ keeps queries of five words or more. Long, specific searches often show what people actually want to know, and they are good input for the topics covered in our SEO basics guide.

Our suggestion: keep the few patterns you use often in a shared document, since a regex filter is gone once you leave the report.

Why the filtered totals look off

A query or page filter changes what the report can count. Google's discrepancies page lists the reasons:

  • Anonymized queries: rare queries are left out of the table "but are included in the chart totals unless a query filter is applied." Once you add a regex query filter, they drop out of the chart too.
  • Row limit: "The table can display a maximum of 1,000 rows", so long-tail rows can be missing from the table while still counted in the chart.
  • Matches plus doesn't match: "the 'match' and 'does not match' totals may not add up to the unfiltered total, due to the omission of anonymized queries and data truncation."
  • Page filters: adding a page filter changes how data is aggregated, "which can cause total clicks and impressions to rise (or, rarely, drop) in the chart."

Google's April 2021 post says it added a reminder that shows "each time a relevant filter is applied on queries or pages", because some data is withheld "to protect user privacy or due to storage limitations." So treat a regex split as a good view of shares and trends, not as exact accounting. For comparisons over time, the Help page also suggests weekly or monthly granularity to smooth out the day-of-the-week effect.

Regex in the Search Console API

The same filtering exists in the Search Analytics API. In the query method, a filter's operator can be includingRegex ("An RE2 syntax regular expression that must be matched") or excludingRegex ("An RE2 syntax regular expression that must not be matched"). The reference lists a "Max length 4096 characters" for filters, and filters within a group are combined with "and"; the "or" group type is "not yet supported." That is useful for long brand lists or for pulling the same pattern into a dashboard every month.

Frequently asked questions

Which regex syntax does Search Console use?

RE2, Google's regular expression library. It does not support lookaheads, lookbehinds or backreferences.

Is the Search Console regex filter case-sensitive?

No, not by default. Put (?-i) at the start of the expression to make it case-sensitive.

How do I exclude queries with regex?

After choosing Custom (regex), switch the second dropdown from Matches regex to Doesn't match regex.

Does the pattern have to match the whole query?

No. Google says matching is partial: the pattern can match anywhere in the query or URL unless you use ^ for the start or $ for the end.

Why don't the matching and non-matching totals add up?

Google says anonymized queries and data truncation are omitted when you filter by query or page, so the two totals may not add up to the unfiltered total.

Can I use regex filters in the Search Console API?

Yes. The Search Analytics query method has includingRegex and excludingRegex operators, both using RE2 syntax.

Reading Search Console data and turning it into page and content decisions is part of our website development work. See all our services, or email [email protected].