AIO Copilot

How to Use Regex in Google Search Console: Syntax, Limits and Tested Patterns

Search Console's regex filter takes RE2 syntax on the Queries and Pages dimensions, matches anywhere in the string unless you anchor it, and ignores case unless you tell it not to. Here are the rules from Google's own documentation, 18 patterns compiled against RE2 itself, and what six of them found on our own site.

Updated 2 November 202613 min read

How do you use regex in Google Search Console?

In the Performance report, click + Add filter, choose Queries or Pages, pick Custom (regex), type the pattern, leave the dropdown on Matches regex or switch it to Doesn't match regex, and apply. Search Console reads the pattern as RE2, Google's regex engine, matches it anywhere in the query or URL unless you anchor it with ^ or $, and ignores upper and lower case by default. Those are the rules in Google's help page for filtering the Performance report.

A regex filter does one job the ordinary "Queries containing" filter cannot: it groups many queries or URLs into one view. One pattern can pull every query that starts with a question word, every query of seven words or more, or every page in three folders at once, and then the chart, totals and table all describe that group.

The rest of this guide covers where the filter sits, which parts of regex RE2 refuses, the limits that change what the totals mean, 18 patterns that each compiled and matched as expected in Google's own RE2 library, and the same filters in the Search Console API and Data Studio. Search Console data is also where most keyword research with AI should start, and regex is the fastest way to cut it into pieces worth reading.

Where is the regex filter in Search Console?

The filter lives in the Performance report for Search results, in the row of filters above the chart. Google's help page gives the sequence:

  1. Click + Add filter in the filters row.
  2. Choose Queries or Pages. These are the only two dimensions that accept regex; country, device and search appearance do not.
  3. Choose Custom (regex) instead of the containing or not containing options.
  4. Type the expression. For several values, separate them with a vertical bar and wrap the whole expression in parentheses.
  5. Keep Matches regex, or choose Doesn't match regex to see everything except the matches.
  6. Click Apply.

Google added the negative option in June 2021, in a Search Central post that also suggested the first patterns most people try: what|how|when|why for queries an FAQ could answer, buy|purchase|order for buying intent, and a list of brand misspellings joined with vertical bars. The help page adds that you can filter by several dimensions at once, so a Queries regex and a Pages regex can run together: question queries, say, that land on blog posts.

The ordinary filters behave differently, and the difference trips people up. "Queries containing" is a plain substring match that ignores case but is otherwise exact, spaces included, according to the same help page. Regex is the only way to say "starts with", "ends with", "this or that" or "exactly six words".

What regex syntax does Search Console support?

Search Console supports RE2 syntax, which covers everyday regex but leaves out lookarounds and backreferences. Google's help page says "The RE2 syntax is used", and the 2021 announcement links to RE2's syntax reference as the list of every metacharacter Search Console accepts. The current version of that reference is the RE2 syntax page on GitHub.

Most of what SEOs need is there. The vertical bar for alternatives, ^ and $ for the start and end of the text, the dot for any character, character classes in square brackets, \d for digits, \s for whitespace and \S for anything else, \b for a word boundary, and counted repetition such as {2,3}. Flags work too: (?i) turns case-insensitive matching on and (?-i) turns it off.

What is missing is everything that needs the engine to backtrack. The RE2 syntax page marks lookaheads (?=...) and (?!...), lookbehinds (?<=...) and (?<!...), backreferences such as \1, possessive quantifiers and atomic groups as "NOT SUPPORTED". It also rejects any counted repetition above 1,000, so \S{1001} fails while an open-ended {6,} is fine. We confirmed each of those refusals by compiling them in the re2 library.

The omission is deliberate. RE2's README says one of its primary guarantees is "that the match time is linear in the length of the input string", and that as a matter of principle it does not support constructs for which only backtracking solutions are known. For a service that runs whatever pattern a user types, that guarantee matters more than lookaheads do.

In practice the missing features have workarounds. A negative lookahead such as "queries without the brand" becomes the brand pattern with Doesn't match regex. "Contains this but not that" on the same dimension needs two filters, which the API allows in one filter group (shown below). A backreference has no substitute, but SEO filters almost never need one.

Is Search Console regex case-sensitive, and how long can it be?

In the Search Console interface, regex matching is not case-sensitive by default. Google's help page says to prepend (?-i) for case-sensitive matches, and gives the example (?-i)AAA, which matches https://example.com/AAA but not https://example.com/aaa. Many patterns published online start with (?i), RE2's case-insensitive flag. In the interface it changes nothing. It matters elsewhere: Data Studio treats regex as case-sensitive by default, and the API reference does not say either way, so keep (?i) in patterns you reuse there.

Google does not publish a length limit for the interface. The Search Console API reference gives a maximum of 4,096 characters for a filter, which is the nearest thing to an official ceiling. A brand list with dozens of misspellings fits comfortably. A pattern that long is usually a sign the work belongs in a spreadsheet.

Two other limits change what a filtered total means, and both come from Google's 2022 explainer on how performance data works. The first is privacy. Queries "that aren't issued by more than a few dozen users over a two-to-three month period" are anonymized: left out of the table, but included in chart totals unless you filter by query. Add any Queries filter, regex included, and those hidden queries drop out of the totals too. A filtered total is therefore the sum of the queries Google was willing to name, never the whole. Long queries tend to be rare, so they are the most likely to be withheld, and a word-count filter undercounts the long end most.

The second is rows. The interface exports at most 1,000 rows. The API returns up to 25,000 rows per request and pages beyond that, with an upper limit of 50,000 rows per day per site per search type, according to the same post. On a large site, regex in the interface shows a slice; regex in the API gets you every row Google is willing to name.

Search Console regex examples that work

Each pattern below compiled in Google's re2 library and matched the sample queries and URLs we wrote for it, including the near misses it should reject. Paste them as they are; Search Console does not need quotation marks or slashes around a pattern.

To findFilterPatternNotes
QuestionsQueries^(who|what|when|where|why|how|which|is|are|can|does|do|should)\bQuery starts with a question word. The \b keeps "island" and "doors" out.
Question words anywhereQueries\b(who|what|when|where|why|how)\bAlso catches "seo audit how long".
Your brandQueriesaio ?copilot|aiocopilotSwap in your brand and its misspellings. "Doesn't match regex" gives non-brand.
One or two wordsQueries^\S+(\s\S+)?$Head terms.
Three or four wordsQueries^\S+(\s\S+){2,3}$The middle of most sites' query lists.
Five or six wordsQueries^\S+(\s\S+){4,5}$Long queries.
Seven or more wordsQueries^(\S+\s){6,}\S+$Conversational queries, often whole sentences.
ComparisonsQueries\b(vs|versus|alternatives?|compared?)\bMatches "vs." too. Add comparison or "difference between" if you want them.
Commercial modifiersQueries\b(best|top|cheapest|price|pricing|cost|review|reviews|buy|hire|software)\bEdit the list for your market.
Local modifiersQueriesnear me|nearby|open now|\b(toronto|mississauga|oakville|markham)\bReplace the place names with your service area.
Queries with a yearQueries\b20[0-9]{2}\bPages that need a yearly refresh.
An exact set of queriesQueries^(seo audit|site audit)$Both anchors, so "free seo audit" is left out.
One folderPages^https://www\.example\.com/blog/Page values are full URLs. Escape the dots.
Several foldersPages/(blog|guides)/Unanchored, so it matches on any host in the property.
Product pages, no subpagesPages/products/[^/]+$Leaves out /products/red-shoe/reviews.
Any URL with parametersPages\?Use "Doesn't match regex" to drop them all.
Tracking parametersPages[?&](utm_[a-z]+|gclid)=Use "Doesn't match regex" to drop campaign-tagged URLs only.
URLs with capital lettersPages(?-i)[A-Z]Case-sensitive switch. Finds /Blog/ living next to /blog/.

Question queries

The question pattern anchors on the start of the query and ends the word list with \b, a word boundary. Without it, the is in the list matches the start of "island" and do the start of "doors". Queries with the question word later, such as "seo audit how long", need the unanchored version. Questions are the queries most likely to deserve a direct answer in the first sentence under a heading.

Brand and non-brand

Write every spelling of the brand people actually type, including spaced and unspaced forms, then flip between Matches and Doesn't match. Keep the pattern specific. On our own property a bare aio would sweep in searches such as "aio tracking" and "aio roadmap", which are about Google's AI Overviews, not about us. Brand traffic tracks awareness; non-brand traffic is where SEO work shows up, so most reports should show the two apart.

Long queries by word count

The word-count patterns count runs of non-space characters. ^\S+(\s\S+){2,3}$ reads as "one word, then two or three more, each after a space, and nothing else". The seven-plus pattern, ^(\S+\s){6,}\S+$, asks for at least six word-and-space pairs and a final word. Because these use both anchors, they never overlap: every query falls in exactly one bucket. A rough alternative is length in characters, ^.{60,}$, but word count separates a specific question from a long product name better.

Comparisons and alternatives

\b(vs|versus|alternatives?|compared?)\b catches "ahrefs vs semrush", "woorank alternatives" and "compared to", but not "comparison", because compared? means compare with an optional d. That was deliberate for our data; add comparison if your market uses it. These are buyers choosing between named products, and they usually want a table, which our guide to competitor analysis covers from the other side.

Pages, folders and parameters

Page filters trip people up because the stored value is the full URL, protocol and host included. ^/blog/ matches nothing; ^https://www\.example\.com/blog/ works. Escape the dots, or . will match any character. To clean parameter noise out of a page report, use \? with Doesn't match regex to drop every URL with a query string, or the narrower tracking-parameter pattern to drop only campaign-tagged URLs. The capital-letter pattern is the one place the (?-i) switch earns its keep: it lists URLs whose paths contain upper case, a common source of duplicate pages.

What these patterns found on our own Search Console data

On aiocopilot.com, queries of seven or more words brought only 6.6% of impressions but held the best average position of any length group, 17.6 against 29.6 for one- and two-word queries. We ran the four word-count patterns, the question pattern and the comparison pattern above over our own property's Search Console Performance export, queries table, for 23 September to 20 October 2026.

On our site, queries of seven or more words ranked best but brought only 6.6% of impressions
Share of impressions
1 or 2 words (120)24.1%
3 or 4 words (534)58.2%
5 or 6 words (171)11.0%
7+ words (175)6.6%
Seven or more wordsShorter queries
Share of impressions in the first 1,000 queries, by query length, aiocopilot.com, 23 September to 20 October 2026
1 or 2 words (120)24.1%
3 or 4 words (534)58.2%
5 or 6 words (171)11.0%
7+ words (175)6.6%
Average position (lower is better)
1 or 2 words29.6
3 or 4 words29.0
5 or 6 words23.2
7+ words17.6
Average position by query length, aiocopilot.com, 23 September to 20 October 2026; lower is better
1 or 2 words29.6
3 or 4 words29.0
5 or 6 words23.2
7+ words17.6
Source: aiocopilot.com's own Search Console Performance export, queries table, 23 September to 20 October 2026: the first 1,000 queries, 22,642 impressions. One small site and one month; queries Google anonymizes are not in the export. Buckets assigned with the word-count patterns in this guide. Filter rules: Google Search Console Help.

Three- and four-word queries carried the site: 534 of the 1,000 queries and 58.2% of their impressions. Five- and six-word queries took 11.0% at an average position of 23.2, and the 175 queries of seven words or more took 6.6% at 17.6. One plausible reason long queries rank better is that fewer pages match every word of a long query, so a page that does match faces less competition. Each one, though, is searched rarely.

The question pattern matched 77 queries with 386 impressions and no clicks at all. The comparison pattern matched 120 queries with 1,460 impressions and 5 clicks. The 1,000 named queries recorded only 9 of the property's 60 clicks in the window, so comparisons took more than half of the clicks Search Console tied to a visible query. With numbers this small it is a hint rather than a finding: on this site, people choosing between named tools clicked, and people asking how something works did not.

Read the numbers for what they are. This is one small site in one month, the export stops at 1,000 rows, and those rows held 22,642 of the 28,546 impressions and 9 of the 60 clicks Search Console counted for the property in the window. The missing share sits in rows past the cap and in queries Google anonymized because too few people searched them. Long queries are the likeliest to be that rare, so the seven-plus bucket is probably the most undercounted. The figures show how this site's visible queries split. They do not show that long queries are worth more in general, or that question queries never earn clicks elsewhere. Run the same patterns on your own export before drawing a conclusion about your site.

How to use regex in the Search Console API

The Search Console API takes regex through two filter operators, includingRegex and excludingRegex. The searchanalytics.query reference describes them as "An RE2 syntax regular expression that must be matched" and "An RE2 syntax regular expression that must not be matched", so every pattern above works unchanged. You can filter on query, page, country, device or search appearance, even if you are not grouping by that dimension, and all filters in a group must be true for a row to be returned.

That group rule is what the interface lacks. This request asks for queries of seven or more words that do not mention a brand, two conditions on the same dimension in one call:

POST https://www.googleapis.com/webmasters/v3/sites/https%3A%2F%2Fwww.example.com%2F/searchAnalytics/query

{
  "startDate": "2026-09-23",
  "endDate": "2026-10-20",
  "dimensions": ["query"],
  "dimensionFilterGroups": [{
    "groupType": "and",
    "filters": [
      { "dimension": "query", "operator": "includingRegex", "expression": "^(\\S+\\s){6,}\\S+$" },
      { "dimension": "query", "operator": "excludingRegex", "expression": "acme|acmee|acme corp" }
    ]
  }],
  "rowLimit": 25000
}

Inside JSON, every backslash in the pattern is doubled, so \S is written \\S. The reference sets rowLimit between 1 and 25,000 with a default of 1,000, and startRow pages through anything larger. Because the API returns far more rows than the interface's 1,000, it is the right place for word-count and question patterns on any site with real traffic.

Exports work too. Google Sheets' REGEXMATCH function uses RE2 as well (Google says it supports RE2 except Unicode character class matching), so a pattern you test in a sheet against your downloaded queries uses the same syntax Search Console accepts.

Regex for Search Console data in Data Studio (formerly Looker Studio)

Data Studio applies regex to Search Console data through filter conditions and calculated fields, with two differences from Search Console that break copied patterns. Google renamed Looker Studio back to Data Studio on 10 April 2026, according to its Google Cloud announcement, and the free version still connects to Search Console.

The first difference is case. Google's page on regular expressions in Data Studio says they "are case-sensitive by default", the opposite of the Search Console interface, so add (?i) to the front. The second is anchoring. In a filter, the RegExp Contains condition searches anywhere in the value, like Search Console, while RegExp Match is "an exact match expression": the whole value must fit. The functions split the same way. REGEXP_CONTAINS matches anywhere and REGEXP_MATCH only matches the entire value.

Whole-value matching suits bucketing. This calculated field sorts every query into the four length groups from the figure above. The R"..." raw-string form, which Google's own examples use, saves doubling the backslashes:

CASE
  WHEN REGEXP_MATCH(Query, R"\S+(\s\S+)?") THEN "1 or 2 words"
  WHEN REGEXP_MATCH(Query, R"\S+(\s\S+){2,3}") THEN "3 or 4 words"
  WHEN REGEXP_MATCH(Query, R"\S+(\s\S+){4,5}") THEN "5 or 6 words"
  ELSE "7 or more words"
END

The Search Console connector offers two tables, Site Impression and URL Impression, and one data source can use only one of them. The connector may roll withheld queries into a single row with a blank value, and Google suggests filtering out null queries, which also keeps them out of the ELSE bucket.

What to do with the queries a regex finds

A regex filter is a sorting tool, and the sorting only pays off if each group leads to a decision about a page. Question queries with impressions and no clicks, as on our site, mean one of two things: the page ranks too low to be clicked, or it ranks without answering the question near the top. Check the position first. If the page is on the first results page, rewrite the first sentence under the matching heading to answer the question, and check the search intent first; the free search intent classifier gives a quick read on a list.

Comparison queries want a page built for the comparison, with a table and a verdict. If several pages pick up the same comparison, that is keyword cannibalization, and the fix is to choose one owner. Long queries are rarely worth a page each. Google's spam policies define scaled content abuse as many pages generated "for the primary purpose of manipulating search rankings and not helping users". Fold long queries into the page that owns the subject, and use our guide to topic clusters to decide which page that is.

Then measure, with the same filters. Save the regex you used, make the change, and compare the filtered pages against similar pages you left alone over the same weeks, the method in our guide to proving an SEO change worked. The free did-it-work check runs that comparison in the browser from two Search Console exports. AIO Copilot's monthly plan reads the same Search Console data across a whole site and ranks the next moves by what they would earn, if you would rather not maintain the patterns yourself.

Whichever route you take, keep the patterns in a file next to the report. A regex is the definition of the group, and a number reported next month means nothing unless it was cut with the same pattern.

Questions

Does Search Console regex support negative lookahead?

No. Search Console uses Google's RE2 engine, which does not support lookaheads, lookbehinds or backreferences, because RE2 only accepts constructs it can match in time proportional to the length of the text. To exclude something, choose "Doesn't match regex" instead of "Matches regex" and write the pattern for what you want to remove.

Why does my Search Console regex return no rows?

The usual causes are syntax RE2 rejects (a lookahead such as (?!...) or a backreference such as \1), anchoring a Page filter on the path when the stored value is a full URL beginning with https://, and a filter so narrow that every match falls among the anonymized queries Search Console withholds. Google's help does not describe an error message for an invalid pattern, so test it first on exported queries in Google Sheets with REGEXMATCH, which also uses RE2.

How do I filter out branded queries in Search Console?

Add a Queries filter, choose Custom (regex), enter your brand and its common misspellings separated by vertical bars, such as acme|acmee|acme corp, and switch the dropdown to "Doesn't match regex". Google's own example in its 2021 announcement used four spellings of one brand name. Check the result by flipping back to "Matches regex" and reading what the pattern catches.

How many characters can a Search Console regex filter have?

The Search Console API reference lists a maximum of 4,096 characters for a filter. Google's help page for the Performance report does not publish a limit for the interface. Patterns long enough to approach that are usually better split into two filters or moved to the API.

Can I use regex in the Search Console Page filter?

Yes. Regex works on the Queries and Pages dimensions only. Page values are full URLs, so a pattern anchored with ^ must start with the protocol and host, for example ^https://www\.example\.com/blog/, with the dots escaped. An unanchored /blog/ matches that folder on any host in the property.

New studies, by email

Our own studies, and what each new release changes for SEO, AEO and Google Ads.

Or get your price for the app