Characters and alternatives
| Symbol | Means | Example | Search Console | Python |
|---|---|---|---|---|
abc | These characters, anywhere in the text | seomatches seo tools, best seo | ✓ works | ✓ works |
. | Any one character | s.omatches seo, sko | ✓ works | ✓ works |
\. | A real dot (escape a symbol with \) | example\.com | ✓ works | ✓ works |
| | Or | price|cost | ✓ works | ✓ works |
( ) | A group | (cheap|best) laptop | ✓ works | ✓ works |
(?: ) | A group that doesn't capture | (?:cheap|best) laptop | ✓ works | ✓ works |
Learn it with exercises: Search Console regex filter: match several keywords at once
Start, end and word boundaries
| Symbol | Means | Example | Search Console | Python |
|---|---|---|---|---|
^ | Start of the text | ^howmatches how to…, not why how | ✓ works | ✓ works |
$ | End of the text | \.pdf$URLs ending in .pdf | ✓ works | ✓ works |
\b | A word boundary | \bpro\bpro, not product | ✓ works | ✓ works |
In Search Console, \b, \d, \w and \s only know plain English (ASCII) characters, so \b can't find the edge of an Arabic or accented word. In Python, they know every alphabet.
Learn it with exercises: Regex starts with and ends with in Search Console
Character classes
| Symbol | Means | Example | Search Console | Python |
|---|---|---|---|---|
[abc] | One character from the list | optimi[sz]eoptimise or optimize | ✓ works | ✓ works |
[^abc] | One character not in the list | [^a-z0-9 ]a symbol or accent | ✓ works | ✓ works |
[a-z] | One character in a range | [0-9]any digit | ✓ works | ✓ works |
\d | A digit | iphone \d+iphone 17 | ✓ works | ✓ works |
\w | A letter, digit or _ | \w+ | ✓ works | ✓ works |
\s | A space | seo\s+tools | ✓ works | ✓ works |
\S | Anything but a space | ^\S+$one-word queries | ✓ works | ✓ works |
\p{L} | Any letter, in any alphabet | \p{Arabic}Arabic queries | ✓ works | ✕ doesn't work |
Python's built-in re doesn't know \p{…}. The third-party regex package does.
Learn it with exercises: Regex case insensitive and word boundary in Search Console
How many times
| Symbol | Means | Example | Search Console | Python |
|---|---|---|---|---|
* | Zero or more | iphone.*caseiphone, then case later | ✓ works | ✓ works |
+ | One or more | \d+17, 2026 | ✓ works | ✓ works |
? | Zero or one | colou?rcolor or colour | ✓ works | ✓ works |
{n} | Exactly n times | \d{4}a year | ✓ works | ✓ works |
{n,} | n times or more | ^\S+(\s+\S+){6,}$7+ word queries | ✓ works | ✓ works |
{n,m} | Between n and m times | ^\S+(\s+\S+){3,5}$4 to 6 words | ✓ works | ✓ works |
*? | As few as possible | <.*?>one tag, not the whole line | ✓ works | ✓ works |
Learn it with exercises: Find long-tail queries in Search Console with regex
Letter case
| Symbol | Means | Example | Search Console | Python |
|---|---|---|---|---|
(?i) | Ignore letter case | (?i)seoSEO, Seo, seo | ✓ works | ✓ works |
(?-i) | Respect letter case from here on | (?-i)[A-Z]URLs with capitals | ✓ works | Partly |
The defaults are opposite. Search Console ignores letter case unless you start with (?-i). Python respects it unless you add (?i) or re.IGNORECASE; Python only accepts (?-i) inside a group, like (?-i:Seo).
Learn it with exercises: Search Console regex for pages
Works in Python, not in Search Console
| Symbol | Means | Example | Search Console | Python |
|---|---|---|---|---|
(?=…) | Followed by… | iphone(?=.*price) | ✕ doesn't work | ✓ works |
(?!…) | Not followed by… | ^(?!.*repair).*iphone | ✕ doesn't work | ✓ works |
(?<=…) | Preceded by… | (?<=/blog/)\w+ | ✕ doesn't work | ✓ works |
(?<!…) | Not preceded by… | (?<!no )sale | ✕ doesn't work | ✓ works |
\1 | The same text as group 1 again | (\w+) \1repeated words | ✕ doesn't work | ✓ works |
Search Console runs RE2, which leaves these out on purpose. A pattern with one of them doesn't throw an error you can see: it just returns nothing. To include one thing and exclude another, use two filters: Matches regex for what you want, and Doesn't match regex for what you don't.
Learn it with exercises: Search Console regex not working? How to test and fix it
Regex patterns for SEO in Search Console
| Task | Pattern |
|---|---|
| A brand and its misspellings | (smart[- ]?store|smrt store) |
| Non-brand queries | the brand pattern, with Doesn't match regex |
| Questions | ^(how|what|why|when|where|which|can|is|does)\b |
| Comparisons | (vs|versus|difference between|compare) |
| Price queries | (price|pricing|cost|how much|cheap) |
| Long-tail queries, 7+ words | ^\S+(\s+\S+){6,}$ |
| Queries with a year | 20\d{2} |
| One section of the site | ^https://example\.com/blog/ |
| PDF files | \.pdf$ |
| URLs with parameters | \? |
| URLs with capital letters | (?-i)[A-Z] |
In Search Console, "Matches regex" finds the pattern anywhere in the query or URL, the way Python's re.search() does. To match the whole text, anchor it with ^ and $, or use re.fullmatch() in Python.
Each of these is built and tested step by step in the free Google Search Console regex course.