Summarize this article with AI
You need every question query that sends traffic to your blog, minus the ones about your brand, and the "contains" filter can't get you there. A regular expression can, as long as it's written for the RE2 engine Search Console uses and you know where the report's filters stop.
That's what this Google Search Console regex cheat sheet is for. You get 18 patterns to copy, and for each one, the accidental matches it's built to dodge. Some jobs one RE2 expression just can't do. For those, you'll see how the API or Sheets picks up the slack, and when Google's built-in brand filter beats writing a brand regex yourself.
How to use Google Search Console regex
Google Search Console (GSC) regex filters use RE2 regular expressions to include or exclude matching queries and page URLs.1 Two decisions come first: Queries or Pages, and whether matches get kept or thrown out. Then remember the defaults. Search Console ignores case and matches anywhere in the string, which is how a perfectly valid expression ends up pulling in more than you meant.
- Open Performance > Search results.
- Click + Add filter in the filters row.
- Choose Queries or Pages.
- Choose Custom (regex) from the dropdown and enter the expression.
- Pick a match direction and hit Apply.
You now have two options: Matches regex and Doesn't match regex.1 The first keeps whatever matches. The second throws it out.
The scope here is the Search results Performance report. Regex filters only work on the Query and Page dimensions.1 In the Discover and Google News performance reports, regex filters are available for page URLs.
| Your task | Start with | First check |
|---|---|---|
| Find a single fixed phrase | Queries containing or URLs containing | The substring includes the spaces you intend |
| Group alternatives, count words, or anchor a match | Custom (regex) | The expression matches your positive examples and rejects your negative examples |
| Exclude a group of terms or paths | Doesn't match regex | You entered what to remove, not what to keep |
| Separate brand traffic | Built-in Branded/Non-branded filter, if available | The classification fits your known brand searches |
The Queries containing and URLs containing filters match a single substring. Their matching ignores case but is otherwise exact, including spaces.1 Need alternatives, or a boundary around a word? That's when a fixed phrase stops working and regex earns its keep.
Key takeaways: Regex here is partial and blind to case unless you say otherwise. A whole-string match needs ^ and $ around it, and case-sensitive work needs (?-i). You can combine filters across multiple dimensions; the limit is one comparison at a time, not two filters.1
The cheat sheet: 18 regex patterns to copy and paste
Use these patterns to group search queries or website sections. Replace the placeholders with your own terms, then copy the RE2 expression and choose the listed dimension and match direction. Inspect the returned values before reporting.
| # | Goal | Regular expression | Dimension / selection | What it selects |
|---|---|---|---|---|
| 1 | Questions at the start | ^(what|how|why|when|where|who|which|can|does|is|are|should)\s |
Query / Matches | Listed opening words followed by whitespace; not “however” or “wholesale” |
| 2 | Informational candidates | ^(what|how|why|when|where|who|which|guide|tutorial|learn)\s |
Query / Matches | Listed openings followed by whitespace, not a complete intent classification |
| 3 | Transactional candidates | \b(buy|price|cost|cheap|deal|discount|order|purchase|coupon)\b |
Query / Matches | Listed whole words anywhere; read the full query |
| 4 | Comparison candidates | \b(best|top|reviews?|compare|vs|alternatives?)\b |
Query / Matches | Listed whole words; “vsco” does not match vs |
| 5 | Include brand variants | (yourbrand|yourbr4nd|your brand) |
Query / Matches | Any listed substring, regardless of case |
| 6 | Exclude brand variants | (yourbrand|yourbr4nd|your brand) |
Query / Doesn't match | Queries without those listed substrings |
| 7 | Exact keyword | ^your exact keyword$ |
Query / Matches | That full query, still case-insensitive by default |
| 8 | Keyword anywhere | your keyword |
Query / Matches | That substring anywhere; the contains filter is enough for a fixed phrase |
| 9 | “How to” openings | ^how\s+to\s |
Query / Matches | “how to” followed by whitespace |
| 10 | Five-plus-word queries | ^(\S+\s+){4,}\S+$ |
Query / Matches | At least five whitespace-separated tokens |
| 11 | One- or two-word queries | ^\S+(\s+\S+)?$ |
Query / Matches | One or two whitespace-separated tokens |
| 12 | A directory | /blog/ |
Page / Matches | URLs containing that path text anywhere |
| 13 | Several directories | /(blog|docs|pricing)(/|$) |
Page / Matches | Those path names followed by a slash or the URL's end |
| 14 | A literal question mark | \? |
Page / Matches | URLs containing ? |
| 15 | A named subdomain | ^https?://blog\.example\.com/ |
Page / Matches | HTTP or HTTPS URLs on that host, followed by a slash |
| 16 | Nine-plus-word queries | ^(\S+\s+){8,}\S+$ |
Query / Matches | At least nine whitespace-separated tokens, not confirmed AI traffic |
| 17 | Conversational openings | ^(how do i|what is the best way to|can you explain)\b |
Query / Matches | Listed phrases at the start, not a measure of voice or AI use |
| 18 | Exclude selected paths | /(admin|staging|test)(/|$) |
Page / Doesn't match | URLs without those path names; it does not establish their index status |
To adapt these regex patterns, choose the literal keywords first, then specify their boundaries and variations. For example, \btools?\b selects “tool” or “tools”; use both anchors if longer keyword phrases should stay out. A tip before adding more alternatives: list a few queries it ought to match, so you can test against them.
Paste the backslashes as well; strip them and \s, \b and \. mean something else entirely. Rows 6 and 18 flip things around: you set the filter to Doesn't match regex, and the pattern names whatever should disappear. A leading hyphen is not a negation operator.
RE2 rules that change your results
Google Search Console uses RE2 syntax. RE2 prioritizes safety and guarantees matching time that grows linearly with the input length.2 It does not support lookaheads, lookbehinds, backreferences, atomic groups, or possessive quantifiers.3
Partial matching: tool can match within a longer string. Use ^tool$ for the full string, ^tool for an opening, or tool$ for an ending.3 Got alternatives? Then the group needs parentheses around it, like ^(cat|dog)$, or the anchors won't apply to all of it.
Case behavior: By default, uppercase and lowercase count as the same letter in both queries and page URLs. For a case-sensitive Page regex, (?-i)AAA matches https://example.com/AAA but not https://example.com/aaa.1 Going the other way with (?i) gets you nothing in a normal filter, because that's already the default.
Special characters: Type example.com/blog as is and its dot matches anything, exampleXcom/blog included. Use example\.com/blog to match only the literal dot.3 Question marks in URL recipes need the same treatment (write \? when you mean an actual question mark). When you adapt one of these patterns, scan your text for special characters before it goes into the custom regex filter.
The short version of regex syntax
| Syntax | Meaning | Example |
|---|---|---|
. |
Any character | s.o matches “seo” or “s-o” |
* |
Zero or more repetitions | ab*c matches “ac” or “abbc” |
+ |
One or more repetitions | \s+ matches a run of whitespace |
? |
Zero or one repetition | colou?r matches “color” or “colour” |
Pipe | and () |
Alternatives and grouping | (cat|dog) matches either term |
[] |
A character from a set | gr[ae]y matches “gray” or “grey” |
^ and $ |
Start and end of the string | ^seo tool$ matches the full phrase |
\s and \S |
Whitespace and non-whitespace | \S+ matches a token without whitespace |
\b |
ASCII word boundary | \bvs\b rejects “vsco” |
{n,} |
At least n repetitions | (\S+\s+){4,} repeats a token-plus-separator group |
(?-i) |
Case-sensitive matching | (?-i)AAA distinguishes uppercase from lowercase |
Most of an expression is plain text; the special characters are what steer it. They decide grouping, repetition, and where a match starts and stops. Treat \b as an ASCII boundary, rather than a general language-aware word separator.3 For question words that must have another word after them, an explicit whitespace character does the job. This keeps the condition easy to inspect.
Patterns that over-match (and the fixed versions)
A regular expression can be valid and still select the wrong searches. Start with examples that should match and examples that should stay out. The table below shows common boundary mistakes and an expression that fixes each one.
| Loose expression | Accidental match or other problem | Fixed version | What changes |
|---|---|---|---|
(how|who) |
“show”, “however”, “wholesale” | ^(how|who)\s |
Requires an opening word followed by whitespace |
^(can|is) |
“canada”, “isle” | ^(can|is)\b |
Requires an ASCII word boundary, but can match a one-word query |
vs |
“vsco” | \bvs\b |
Selects vs as a whole ASCII word |
example.com |
“exampleXcom” | example\.com |
Makes the dot literal |
-.*yourbrand.* |
Looks for a literal hyphen before the brand | (yourbrand|your brand) with Doesn't match regex |
Uses the report's exclusion control |
^https://blog\. |
Restricts the protocol and does not name the full host | ^https?://blog\.example\.com/ |
Defines both protocol variants and the intended host |
For opening questions, \s makes the separator visible in the copied expression. In the figure, a plain space does that job instead. Should a one-word query count too, or punctuation right after the opening word? Then \b is the better pick.

Turn filtered queries and pages into an action list
Use filtered results to find content worth checking, then inspect the landing page before assigning work. A low position alone does not diagnose weak content. Positions also shift because of algorithm updates and technical issues, and some of it's just seasonality.

Find question queries worth reviewing
Apply the question-opening expression from the table and sort by impressions. Read each query and inspect its landing page. Is the answer missing? Buried? Or does it really deserve its own article?
From there, the worksheet below turns a candidate into one specific editorial task. Write the observation down on its own line, apart from the fix you're proposing. A ranking or CTR signal can suggest work without explaining the cause.
Question-to-action worksheet
Search query:
Landing page:
Report dates and other filters:
Observation: impressions / clicks / CTR / position
Does the page answer the actual question?
Proposed action: keep / improve an answer / add a section / consider a separate page
What to check after the change:
Check search intent against the landing page
Run the informational, transactional, and comparison expressions separately. Each label gives you a queue to review. A buying word doesn't settle the intent: someone using it may still want information. Treat the label as somewhere to begin the review. Before making a change, read the query in full alongside the landing page.
High-impression informational queries with low CTR → Your title/meta description may not match the question.4 Do they accurately describe the answer a visitor will find? Only then decide whether either needs rewriting.
| Candidate segment | Suggested action | How to validate the decision |
|---|---|---|
| Opening questions with weak CTR | Review the title, description, and answer's placement | Compare the full query with the promise and content of the page |
| Buying terms leading to an article | Add a useful buying route or consider a dedicated landing page | Check whether the article can answer the query without changing its purpose |
| Comparison terms leading to a general page | Add the comparison readers need or consider a comparison page | Confirm which alternatives or criteria the query names |

Finding long-tail keywords by word count
Want every query that's five words or longer? Filter on ^(\S+\s+){4,}\S+$. Each repeated group matches a non-whitespace token followed by whitespace; at least four groups plus a final token give at least five words.3 Those ^ and $ anchors force the match to cover the entire query.

Whitespace is the separator here, which leaves e-commerce as one token, just like don't. In this worksheet, long-tail just means long. Group the queries by length and don't read buying intent or easier competition into them. The useful part is the detail inside them, things your existing content could address. Review all of them and prioritize the queries your content can address. You can raise or lower the minimum by editing the number in {4,}; keep both anchors in place.
Compare URL sections with the same report settings
One section? /blog/ works as a path substring. Google Search Console can match several sections together with an expression such as /(blog|docs|pricing)(/|$). Google's example shoes/.*/green selects URLs with that directory sequence and intervening text. Swap blog, docs and pricing for whatever your real paths are.
Check one section per run, keeping the dates, country, device and search type identical every time. You can combine Page and Query regex filters, such as a directory plus the opening-question expression.1 Write the filter settings down with the metrics; otherwise a later comparison has nothing to line up with.

Picture a section with 80% of impressions but only 20% of clicks. The shares alone won't tell you the fix. Look at its query mix and page titles first. After that check, use the thin content assessment workflow for a content review.
Brand vs non-brand: the built-in filter or regex?
Google Search Console's Search results Performance report has a built-in branded queries filter for eligible properties. It offers Branded and Non-branded views across web, image, video, and news search types.4 There's a branded versus non-branded clicks card in the Insights report, too.
Under the hood, Google sorts these with an internal AI-assisted system. No regex involved. It's smart enough to spot your brand in other languages, misspelled, or as the name of one of your unique products. It isn't perfect, and some searches get mislabeled. Availability requires a top-level property with sufficient query and impression volume; URL-path and subdomain properties are not eligible.5
| Situation | Suggested choice | Check before reporting |
|---|---|---|
| The built-in filter is available | Start with Branded and Non-branded | Review known brand and product searches for classification errors |
| A URL-path or subdomain property, or no available branded filter | Define a brand regex | Include the variants your analysis should cover |
| You need a repeatable custom definition | Keep your own expression | Document whether short names should match as substrings or whole words |
| You want to audit the native classification | Compare it with a custom brand list | Investigate differences rather than assuming either definition is complete |
For a hand-built brand regex, Google's sample strings the variants together like this: willow tree|wilow tree|willowtree|willowtee. With Matches regex you'd see just those variations, and switching to Doesn't match regex hides them instead. List whichever names and misspellings matter. Uppercase duplicates are wasted characters, since case doesn't count here.

Reporting a change in clicks? Show branded and non-branded results side by side. And don't treat non-branded clicks as proof that every visitor is new to your business. The labels describe search wording, so keep your conclusion tied to what you measured.
Search Console filters: what works and where they stop
Google Search Console supports filters across multiple dimensions at once.1 You can analyze opening questions for a directory while restricting country and device in Search results. Date comparisons work too, and your other filters stay on while you run them.
Its limits are about comparison scope and expression logic, plus the data that's actually available. RE2 does not support negative lookahead.3 So a reusable rule like question words AND NOT brand can't be a lookahead recipe. Build it in the Search Analytics API or an exported worksheet.
| Feature or task | Scope and constraint | Practical consequence |
|---|---|---|
| Multiple dimensions | Simultaneous filtering is supported | Combine query, page, and other report filters as needed |
| Comparisons | One comparison at a time; device, search type, country, and search appearance comparisons are limited to two items | Pick the dimension you need to compare; the table adds a Difference column |
| Query or URL filtering | Totals can change because of data truncation and omitted anonymized queries | Don't treat a filtered total as a complete split of the unfiltered chart |
| Query exclusions | Anonymized queries are omitted when a filter is applied | Matches plus non-matches can sum to less than the chart total |
| Search Console UI export | Maximum 1,000 rows | A spreadsheet formula evaluates the export, not all possible matching searches |
The Search Analytics API handles AND-NOT logic
The Search Analytics API splits it into includingRegex, for what stays, and excludingRegex, for what goes, both written in RE2. Within an and filter group, all filters must be true; or groups are not supported.6 The fragment restricts the page to /blog/ and the query to a question-word opening, with the brand excluded.
{
"dimensionFilterGroups": [
{
"groupType": "and",
"filters": [
{
"dimension": "query",
"operator": "includingRegex",
"expression": "(?i)^(what|how|why|when|where|who|which|can|does|is|are|should)\\s"
},
{
"dimension": "query",
"operator": "excludingRegex",
"expression": "(?i)(yourbrand|your brand)"
},
{
"dimension": "page",
"operator": "includingRegex",
"expression": "(?i)/blog/"
}
]
}
]
}
You can't send this fragment as a request on its own. Dates and dimensions go in the request around it. Your own terms go in the placeholders. JSON needs \\s to represent the regex's \s. The explicit (?i) flags request case-insensitive matching in these API expressions.3
There's a ceiling on length as well, and it's 4,096 characters per filter. Its rowLimit defaults to 1,000 and can reach 25,000 per request, with startRow for paging.6 Google puts the API's upper limit at 50,000 rows per day per site per search type and says it may not be reached.7 Paging through results won't get you everything.
Bigger reporting jobs are covered in our guide on how to bulk export Search Console data. Decide on the extraction route first and build the worksheet second, then write that route's coverage limits next to the results.
Use Sheets for a reviewable query worksheet
Paste your exported Google Search Console queries into column A. Next to the first data row goes this formula, which flags opening questions without a brand variant (fill it down from there):
=AND(REGEXMATCH(A2,"(?i)^(what|how|why|when|where|who|which|can|does|is|are|should)\s"),NOT(REGEXMATCH(A2,"(?i)(yourbrand|your brand)")))
Why the (?i) flags? They make the sheet ignore case, just like Search Console's regex does by default. Google Docs Editors Help says Sheets' REGEXMATCH supports RE2 except Unicode character class matching.8 Put your own brand list in. Run a few known hits and known misses through it before filtering on what it returns.
A worksheet based on the Search Console UI export still has that export's 1,000-row limit.7 And no formula can bring back anonymized searches the export never had. Mention both limits whenever you share the totals.
Measure AI search traffic, not just long queries
Google Search Central said in 2025 that users of its AI search experiences ask longer and more specific questions.9 That doesn't mean a word count can filter AI traffic, however tempting it is. You can, though, pull requests of nine words or more with ^(\S+\s+){8,}\S+$ and read through them, as long as none get labeled confirmed AI searches.
Google Search Console already counts AI Overviews and AI Mode traffic, inside the Web search type of the Search results Performance report. Impressions from those experiences get their own Generative AI performance report, split by page, country, device, and date. It has no query dimension and excludes Search Labs experiments.10
| Reporting question | Use | What you can conclude |
|---|---|---|
| Which detailed requests could inform our content? | Word-count or conversational-opening regex in Search results | The visible queries match your wording or length rule |
| Which pages receive AI Overviews or AI Mode impressions? | Generative AI performance report | AI impressions for the report's page, country, device, and date breakdowns |
| Is the share of long visible queries changing? | Repeat the same length filter and comparison method | A change in the measured length segment, not a change in AI traffic by itself |

When comparing long-query shares, keep the dates, filters, and denominator consistent. Remember that filtered query totals omit anonymized queries.7 Use the actual wording to plan answers, and keep AI impression reporting separate.
Why your regex returns zero results
The culprit behind an empty report could be the expression or the analysis settings. Unsupported syntax will fail, of course. But an empty table doesn't reveal which of those causes left you without results. Start again with a term you know is present, adding one constraint back at a time.
- Check syntax: Strip out
(?=...)and(?!...), lookbehinds, backreferences, and other unsupported constructs.3 - Check case: Matching ignores case by default.1 Did you mean to add
(?-i)? If not, remove it to turn off case sensitivity. - Check special characters: Escape dots and question marks when your URL expression needs to match them literally.
- Check dimension and direction: A Page expression belongs in Pages; Doesn't match regex excludes the text you entered.
- Check report coverage: Widen the date range and remove other filters while testing. Missing anonymized queries and data truncation can also affect what is available.1
- Check boundaries: An exact or opening match can exclude text that a substring match would keep.

Test strings that should and shouldn't match
Pick the Golang flavor in regex101, since its syntax comes close. Go's regular expression syntax follows RE2 except for \C.11 Set the case-insensitive i flag, or add (?i), to mimic Search Console's default while testing.
For ^(how|who)\s, test these strings separately. The expected matches are “how to compare tools” and “who is this for”; “however useful” and “wholesale tools” should stay out.
how to compare tools
who is this for
however useful
wholesale tools
A successful outside test does not guarantee that the report contains matching data. After applying the regex filter in Search Console, inspect the returned queries or pages. Check both representative matches and cases that should have been excluded.
Save a segment record you can reuse
Keep a library of regular expressions with their analysis settings attached. This helps you repeat an analysis without losing the segment definition. Copy this record for your next reporting task:
Segment name:
Product and report:
Dimension: Query / Page
Selection: Matches regex / Doesn't match regex
Expression:
Positive test examples:
Negative test examples:
Dates, search type, country, device and other filters:
Comparison, if any:
Metric and denominator:
Export method and coverage limits:
Action or finding:
Before saving your custom regex, check that it selects the expected values and that the exclusions work. When the report comes around again, reuse the same settings in Google Search Console and spot-check a fresh sample. Totals don't match? Before you call it a tracking error, rule out truncation and the anonymized queries that get left out.
Page URLs work with REGEXMATCH the same way. With SEO Heatmap, clicks for every page go out to Sheets or Excel with no 1,000-row cap like the Search Console UI has. Your section expression then runs on the whole site, not the top rows. For query-based segments, though, you'll need Search Console or the Search Analytics API.
Frequently asked questions
How can I add a regex filter in Google Search Console?
In the Search results Performance report, click + Add filter. Choose Queries or Pages from the options, and then Custom (regex). Type in the expression, set it to Matches regex or Doesn't match regex, and hit Apply. The Discover and Google News performance reports let you filter page URLs with regex too.
Is Google Search Console regex case-sensitive?
Not unless you make it. Queries and page URLs both match regardless of case. Put (?-i) at the start if you want case-sensitive matching. You don't need (?i) here; ignoring case is already the default.
Is contains ever a better choice than regex?
Contains is for a single fixed substring. Regex is for when you need alternatives, boundaries, or word counts. Case doesn't matter to contains, but spaces do, along with every other character in the substring. Regex matches partial strings by default too. Anchor it if you want the complete string.
Does a lookahead such as (?=...) work in Search Console?
No. RE2 runs Search Console's regex filters, and it doesn't support lookaheads such as (?=...) or (?!...). Lookbehinds and backreferences aren't supported either. To exclude, switch to Doesn't match regex, and to include and exclude queries at once, use an AND group in the API or the Sheets worksheet.
Why does my regex return zero results after it passes an outside test?
An outside test does not show whether Search Console has matching data under your selected settings. Look first at the dimension and match direction you chose. After that come the anchors, the date range and any other filters on the report. Outside Search Console, regex101 set to the Golang flavor with case-insensitive matching gets you close. Then look at the actual report.
Why don't matching and non-matching query totals add up?
Once a filter is on, anonymized queries drop out. That's why matching plus non-matching can come up short of the unfiltered chart. Data truncation is another factor when you filter by query or URL. And a Search Console UI export stops at 1,000 rows, so a worksheet built from it only covers what that export holds.
Can I combine a question regex with a brand exclusion in the API?
Yes, the Search Analytics API supports includingRegex and excludingRegex in the same and filter group. Every filter in the group has to be true. Each one has to fit in 4,096 characters, too. The API example earlier in this guide already has a page condition built in; you just swap in your own brand terms.
Can a long-query regex identify AI Overviews or AI Mode traffic?
No, a word-count regex identifies query length, rather than confirmed AI search traffic. AI Overviews and AI Mode traffic is included in the Web search type of the Search results Performance report. There's also the Generative AI performance report, with impressions by page, country, device, and date. It has no query dimension and leaves out Search Labs experiments.
Found a page group worth keeping an eye on? Narrow SEO Heatmap to it with the contains and doesn't-contain URL filters, and you'll see its clicks month by month for 16 months or week by week for 16 weeks. It's free for one Search Console property.
Sources (11)
SEO Heatmap Knowledge relies on primary sources: Google's documentation, web standards, peer-reviewed research, and vendors' own pages for their pricing and features. Our editorial standards
- Google Search Console Help. “Performance report (Search results): Advanced filtering and comparison.”
- Google RE2. “RE2, a regular expression library.”
- Google RE2. “Syntax.”
- Google Search Console Help. “Performance report (Search results): Common tasks and use cases.”
- Google Search Central. “Introducing the branded queries filter in Search Console.”
- Google Search Console API. “Search Analytics: query.”
- Google Search Central. “A deep dive into Search Console performance data filtering and limits.”
- Google Docs Editors Help. “REGEXMATCH.”
- Google Search Central. “Top ways to ensure your content performs well in Google's AI experiences on Search.”
- Google Search Console Help. “Generative AI performance report (Search).”
- The Go Project. “regexp package.”