Search Console Regex Filter: Match Several Keywords at Once

About 20 minutes

In the last lesson we agreed on a rule we'll follow for the whole course: we won't start from regex; we'll start from an SEO question.

Today the question is very simple. Say you have Search Console open, with these queries:

  • iphone 17 price
  • iphone 17 cost
  • how much is iphone 17
  • buy iphone 17
  • best iphone 17
  • iphone 17 specs

And you want to know: which queries are the searcher asking about the price?

If you only wanted one word, like "price", you could use a normal filter. But the problem is that people don't search with the same wording. One types "price", another "cost", and another "how much".

You don't need three separate filters here. You need to tell Search Console: show me any query that contains "price" or "cost" or "how much". That's where the first real use of regex begins.

Before we write regex, let's understand the problem

The question isn't "search for a word". What the queries share isn't one word: we have several options: price, cost, how much. So our problem is "search for one of several words". And that's the first thing regex will solve for us.

The first symbol we'll learn: |

The | symbol simply means "or". So if you write price|cost, you're saying: match "price" or "cost".

Let's try it:

price|cost
  • iphone price
  • iphone cost
  • buy iphone
  • best iphone

Why? Because every query that showed up contains one of the two options we wrote.

Add more options

Now, instead of two options we have three: price, cost, how much. We can write price|cost|how much, which means: price or cost or how much. Nothing more complicated than that so far. Let's test it.

price|cost|how much
  • iphone 17 price
  • iphone prices in the us
  • cost of buying an iphone
  • how much is the iphone 17 pro
  • buy iphone on monthly payments
  • iphone specs

Notice "iphone prices in the us". We never wrote "prices", and it still showed up. Why? Hold that thought; the answer is in the next section.

And notice we're doing the same thing we agreed on in the mindset lesson.

The rule
We predict the result first, then we run the regex.

But how did Search Console find the word?

This is a very important point before we go on. When you write "price", Search Console doesn't say "the query has to be just price". By default it uses a partial match: it looks for the pattern anywhere inside the text.

price
  • iphone price
  • what is the iphone price
  • iphone price in the us
  • iphone prices

Because "price" is inside every one of these queries, "prices" included: the first five letters of "prices" are "price". This is a very important point.

If you think regex has to match the whole text, you'll build patterns more complicated than you need.

Predict the result

Here's the pattern, and here are five queries. How many will match?

iphone
  • iphone
  • iphone price
  • iphone 17 pro
  • best alternative to the iphone
  • samsung

Why didn't samsung show up? Because Search Console looks for the pattern inside the text; the whole text doesn't have to equal it. In a later lesson we'll learn how to tell it: the text starts with this, or the whole text is exactly this. But we don't need that now.

So why will we use brackets ()?

We could write price|cost|how much, and it works. But you'll usually see it written like this: (price|cost|how much). The brackets () mean we're grouping part of the pattern together. In our simple example the result is about the same with or without the brackets, but later we'll need to treat the whole group as one piece of a bigger pattern. So from now on, when you see (), read it as "this is a group", not as a mysterious symbol you have to memorize.

Let's take a real regex apart, piece by piece. Don't look at it as one sentence:

(price|cost|how much), piece by piece
  1. 1( — these are one group
  2. 2price
  3. 3| — means or
  4. 4cost
  5. 5| — means or
  6. 6how much
  7. 7) — the end of the group

So the meaning is: look for "price" or "cost" or "how much". That's it. If you understand that meaning, you've written your first real regex.

Using it in Search Console

Search Console currently lets you use regex on queries or pages in the Performance report. You get there from the filters: Add filter → Query or Page → Custom (regex). Then you choose Matches regex or Doesn't match regex.

Note
Matches regex: show me every row the regex applies to. Doesn't match regex: show me everything it doesn't apply to. That will matter a lot later, when we split brand from non-brand with exactly the same pattern.

A first real SEO use: brand queries

Say your brand name is written in more than one way. For example, a made-up company called Tech Zone, and people search: tech zone, techzone, tech-zone, tech zone uk. If you made a filter for tech zone only, you could lose techzone and tech-zone. So we can do:

(tech zone|techzone|tech-zone)
  • tech zone
  • techzone
  • tech-zone
  • best laptop

Now we're saying: any query with any form of these brand spellings goes in the group I want to see. Notice something important: regex itself doesn't know these are brand queries. We told it the different brand names. It just did the matching.

What happens if the regex is incomplete?

Say people also type "teck zone", a typo, but we wrote the same pattern as above:

(tech zone|techzone|tech-zone)
  • tech zone
  • techzone
  • tech-zone
  • teck zone
Watch out
The query "teck zone" won't show up. That's a false negative: a result we want, but the pattern doesn't cover. When you build a brand regex, your job isn't just to know the syntax. You need to know how people actually type the brand. And that's an SEO point that matters more than regex itself.

Another example: comparison queries

You have: iphone vs samsung, iphone versus samsung, difference between iphone and samsung, iphone price, best iphone. We can start with a simple rule:

(vs|versus|difference between)
  • iphone vs samsung
  • iphone versus samsung
  • difference between iphone and samsung
  • iphone price
  • best iphone

Now you have a segment for queries that contain comparison modifiers. But don't call it "all the comparison queries on the site", because someone might search "iphone or samsung which is better", and our pattern won't catch it. So a regex reflects the rules you wrote, not every way a person could phrase the same idea.

Regex doesn't understand synonyms on its own

If you write "price", Search Console won't think "cost means something close to price, I'll bring that too". No: it isn't semantic search. If you want price and cost and how much, you have to spell them out yourself.

The rule
Regex is very literal, and that's actually part of its power. You decide the rule exactly.

Do the spaces around | matter?

Look at price|cost and price | cost. The second has real spaces around the |. And in regex a space isn't necessarily just visual formatting: it's a character that can take part in the match. So when you write a simple alternation, it's best to write the words right up against the bar, unless you know exactly that the spaces are part of what you want to match.

Search Console ignores capital and small letters by default

This matters a lot in English. If you have iphone, IPHONE and iPhone, and you write "iphone", regex matching in Search Console is case-insensitive by default:

iphone
  • iphone
  • IPHONE
  • iPhone

So you don't need to write (iphone|IPHONE|iPhone) for that reason alone. Later we'll learn how to make matching case-sensitive when we have a real reason to.

Do I have to put () every time I use |?

Technically, no. But in this course we'll usually write a clear set of options in brackets, because it's easier to read, and more importantly, it prepares us for when we start building bigger patterns.

Let's do a small complete analysis

Say you have a site that sells laptops, and the question is: I want to study the queries where the searcher clearly mentions price.

The analysis steps
  1. 1Pick the words: price, cost, how much
  2. 2Build the simplest pattern: (price|cost|how much)
  3. 3Predict the result before running it
  4. 4Apply it: Query → Custom (regex) → Matches regex
  5. 5Review: did unexpected queries show up? Did we miss words like pricing or cheap?
(price|cost|how much)
  • lenovo laptop
  • lenovo laptop price
  • lenovo laptops prices
  • gaming laptop cost
  • buy lenovo laptop
  • how much is a lenovo laptop
  • best laptop for work
  • laptop on finance

Something very important showed up here

After looking at the data, you also found "lenovo laptop pricing" and "cheap lenovo laptop". Notice that "pricing" doesn't contain "price": the letters are p-r-i-c-i-n-g, not p-r-i-c-e. The question is: are these part of the segment I'm building? If yes, we add them:

(price|pricing|cost|how much|cheap)
  • lenovo laptop pricing
  • cheap lenovo laptop
  • lenovo laptop price

Notice how we work. We didn't try, from the first minute, to imagine every option in the language. We started with a simple pattern, looked at the results, learned from the data, and widened it. That's a very practical way to build regex.

A common mistake: building regex from your imagination alone

If you're building a brand regex or a commercial regex, don't just sit and guess the words people might use. Start with something sensible, then review the actual Search Console data:

The right way
  1. 1The data
  2. 2A first pattern
  3. 3A test
  4. 4Finding new phrasings
  5. 5Improving the pattern
Watch out
Not: "I'm smart and I'll predict everything → one huge pattern → done". Users can type phrasings you never thought of.

So what did we actually learn?

So far we've learned just 3 things. First: plain text. If you write "price", we're looking for the text "price", and in Search Console the match is a partial match by default. Second: | means "or". Third: () groups parts of a pattern together. That's all. You don't need to memorize 15 more symbols.

Try it yourself

You have: buy iphone, iphone price, iphone on finance, iphone cost, how much is an iphone, best iphone, iphone prices. You want a pattern for the queries about price. Write the regex before you look at the solution.

  • buy iphone
  • iphone price
  • iphone on finance
  • iphone cost
  • how much is an iphone
  • best iphone
  • iphone prices
Try it yourself

You have a made-up brand that people type like this: seo lab, seolab, seo-lab. Write a regex that brings the three spellings together.

  • seo lab
  • seolab
  • seo-lab

With Matches regex it pulls out the brand queries, and with Doesn't match regex it leaves them out of the results.

Try it yourself

You have: iphone vs samsung, iphone versus samsung, difference between iphone and samsung, best iphone, iphone price. Write a pattern that brings together the three comparison phrasings.

  • iphone vs samsung
  • iphone versus samsung
  • difference between iphone and samsung
  • best iphone
  • iphone price

Before you treat the result as complete, think: could a user express the comparison another way? Like "iphone or samsung which is better". If yes, you have a practical example of a pattern that needs to learn from the data.

The practical test

You have queries about the macbook pro. Decide for yourself which words or phrases you count as asking about the price, and write one regex that brings them together.

Regex challenge

A price segment for the macbook pro

Write one pattern that brings together every query about price, and leaves out every other query.

Must match
  • · macbook pro price
  • · macbook pro prices uk
  • · macbook pro cost
  • · how much is a macbook pro
  • · macbook pro pricing
  • · cheap macbook pro
Must not match
  • · buy macbook pro
  • · best macbook pro
  • · macbook pro specs

Once you've built the segment, think of one SEO question you could use it to answer. Not "I managed to pull out the queries", but something like: do price queries get a lower CTR than the rest? Or which landing pages show up most for price queries? That's where regex starts turning from a filter into an analysis tool.

Before you go to the next lesson

If you understood the lesson, you should look at (price|cost|how much) and not see strange code. You should see a simple sentence meaning "price or cost or how much", and also understand that Search Console isn't trying to understand what those words mean. You chose them.

In the next lesson we face a different problem. So far, if we write "iphone", Search Console can find it anywhere in a query. But what if I want queries that start with a particular word? Or end with one? Or equal a particular phrase exactly? That's where we'll need to control where the match happens, and it will be the first time we build a pattern more precise than just searching for words.

Well done, you reached the end of the lesson.