In this article, we study the interest of using regular expressions (Regex) in the Google Search Console. We see that it is a very powerful filtering system that allows you to highlight pages or queries according to specific filters and thus to have elements of analysis for your SEO (natural referencing). You will also discover concrete examples of how to use the regexes for your property in the Search Console!
To further analyse your SEO performance in Google Search Console, you can use filters.
There are several types of filters. First of all, in Performance > Search Results you can choose the type of search (Web, Images, Videos, News). You can also filter by date. Finally, we can click on "+ new" to have filters on queries, pages, countries, devices or appearance in the search results. Filtering options are already offered in all these categories. However, you can customise your filtering for queries or pages using regular expressions (regex).
1 - What is a regular expression (Regex)?
Regular expressions or Regex can be defined simply as expression recognition. To put it differently, Regexes will retrieve precise information and retransmit it thanks to a specific language. These regular expressions will, in fact, through a command that we give, detect and reveal (precise) expressions that we wish to have.
In Google Search Console, the Regex will allow you to filter the results of the most frequent queries and the most popular pages. In a more concrete way, I could, for example, see and study the number of impressions and the number of clicks only for queries that include a number. I could, for example, also see which URLs that are not secure (http: and not https:) appear in Google search results and on which queries they appear.
2 - How to use regular expressions (regex) in Search Console?
To use regular expressions (regex) in Google Search Console, it is very simple. To do this, you need to :
- Step 1: Login to Search Console
- Step 2: Go to the Search Results in the "Performance" tab
- Step 3: Click on "+ new" (next to Date)
- Step 4: Select either "queries" or "pages
- Step 5: Choose "custom (regular expression)" instead of "containing queries" or "containing URL".
You can now type your regular expression. In addition to that, you have 2 options. You have the choice between the filter that matches the regular expression or the filter that does not match the regular expression. In the second case, for example if you had typed a regex to filter out queries containing a number then you would have all queries except those containing a number.
3 - The different regular expression filters
Regular expressions are based on a very specific language that you need to know. In this section, we will briefly present some syntax rules before presenting concrete examples. Here is a non-exhaustive list of the different characters used in regular expressions and their description:
- ^: Start of string character that limits matches to the beginning of the string (e.g. "^who" will match expressions starting with "who ...")
- $: End-of-string character that limits matches to the end of the string (e.g. "^?" will match expressions that end with a question mark)
- |: Corresponds to the word "or", i.e. it corresponds to the expression in front OR behind the vertical bar (For example : "Digidop | Digi", will correspond to both "Digidop" and "Digi")
- [ ]: Corresponds to the set of characters between brackets (For example : "Di[gmb]idop" corresponds either to "Digidop", or to "Dimidop", or to "Dibidop")
- ( ): Corresponds to the whole group
- - Character interval in the [ ].
[a-z]: Lower case letters from a to z
[A-Z]: Capital letters from A to Z
[0-9]: Numbers from 0 to 9
Of course, combinations can be made to select a specific range. For example [d-g1] for lower case letters from d to g or digit 1
- . (For example: "Dig.dop" corresponds to "Digidop" as well as to "Digodop" or even "Digjdop")
- * : corresponds to the previous character 0 or more times
- +: matches the previous character 1 or more times
- ? corresponds to the previous character 0 or 1 time
- {min,max} : correspond au nombre de mots entre la valeur minimale et maximale
- {min,} : correspond au nombre de mots entre la valeur minimale et l’infini
- {,max} : correspond au nombre de mots entre 0 et la valeur maximale
- {nombre} : correspond au nombre de mots inscrit dans l’accolade
- \w: corresponds to all characters from a to z, from A to Z and from 0 to 9 ([a-zA-Z0-9_])
- \d: corresponds to a number ([0-9])
- \D: Does not correspond to a number (inverse of \d)
- \s: corresponds to a blank space (For example : "digi\sdop" corresponds to "digi dop")
- \S: Does not correspond to a white space
4 - Examples of regular expressions used in the Search Console
This language may seem a bit complicated, but don't worry, in this section we will give you some useful examples of regexes to use.
^(who|when|how|where|why|what)[" "]: This regular expression allows you to sort your queries according to the questions. This means that you will get all the queries on which you are positioned beginning with who / when / how etc. Very useful when you want to know the questions that Internet users are asking.
^(vs|price|advice|buy|order|promotion|comparative|best|best)[" "]: This expression is a variation of the previous one, but is more useful for e-commerce. It allows you to sort the queries in the Search Console according to the words price / best etc.
^(winter|spring|summer|autumn)[" "]: A final example of declining the previous regexes. For example here to filter queries by seasonality. Customise this expression as you wish by changing the keywords.
([^” “]*\s){5,}? : Cette regex vous montrera toutes les requêtes contenant 6 mots ou plus. Vous pouvez bien entendu changer le chiffre pour personnalisé votre filtrage. Pratique pour identifier vos longues traînes.
(\w+\s){5,}\w+ : Une variante de l’expression précédente somme toute similaire
^http: This regular expression will be useful (to be inserted in the "page" type) to check the URLs of your site that are not secure.
web(flow)? Listof queries containing the word Web necessarily and Webflow
^web(flow)?(design)?$ : List of queries containing the word Web necessarily and Webflow or Webdesign
\List of keywords/queries containing a number
These are just a few examples, but here is an illustration of what you can already achieve. For more information, you can go directly to the Google search performance report or to the Re2 syntax.
On the other hand, if you need help building your SEO strategy, Digidop is there for you!