Google Regular Expressions (RegEx) –

The They represent a highly useful resource to make the most of the power of this tool’s filters, maximizing and optimizing the performance we get to do our different analyses.

But the regular expressions or RegEx, especially at first, are complex to understand. Although with experience and use you will use them a lot and you will notice that they are so useful that you will know that you would have saved a lot of time of your life that you lost filtering by hand if you had known them before.

What are regular expressions?

The regular expressions or RegEx (Regular Expressions), consist of a series of characters that can be used to narrow a search to the desired patterns. With them it is possible to carry out tasks such as extracting a list of e-mails from a report or knowing how many pages of a website include one or several specific words in their URL.

When we need to search for specific words on the Internet, many people know a series of tricks that make the job easier. For example, if you enter “related:” in Google and then the address of a web page, the search engine will return web pages similar to the one you indicate. In this direction regular expressions focus.

In order to use them, we will use tools that support their use and that are linked to the world of digital marketing:

  • Crawlers for on-page optimization.
  • Google Analytics and its custom filters.
  • Text editors such as notepad or Word.
  • Google Sheets, spreadsheets that help organize all the information obtained.
  • Programming languages.

Once familiar with the semantics of RegEx it is possible to save a lot of time and effort when working with data without a logical order.

See also  Google Multisearch: The Mobile Search Revolution -

Basic Regular Expression Patterns Google

The regular expressions they use the same characters and numbers that we are used to using on a daily basis: letters (AZ) and numbers (1-9), in addition to certain normal symbols on our keyboards, which are:

. A point

It means that you can match any single character in the pattern instead: a letter, a number, a punctuation mark, or a space, but not an end-of-line character. Sometimes, when in the pattern you want to specifically identify the value of the period (.) not the wildcard, you will need to escape and for that you will have to proceed from the backslash to make it literal:\.

\ The backslash or backslug

It is the escape character, which we have seen at the end of the previous point.

brackets

They are used when we identify in a pattern the coincidence of one and only one of the elements that we put in the bracket. For words it is not valid, only for characters one by one.

– The middle dash

It is to create a range in a list. For example is exactly the same as .

^ Circumflex accent

If this symbol is in square brackets, it means NO; eg: will be anything but a one-digit number. Outside the brackets identifies something that is at the beginning of a line.

$ Dollar

It means that the element it accompanies must end a line. For example: https://jbmoreno.es$ identifies only the home of my site and not any URL.

? Question mark

Matches zero or one (not more) of the preceding items, so y? will match yo yy, but not yyy.

See also  What is the CPC? -

+More

The plus sign (+) added to a character or wildcard will cause the pattern to match -at least- one or more matches.

*Asterisk

It is a combination of the previous two. Thus, an asterisk accompanying a character or wildcard means that you are looking for the match of zero, one or more of the elements that it accompanies. So y* will either match an empty string or it will also match y, yy, yyy or any number of repeated ‘y’s in a row.

{} The keys

They are used to identify an exact number of repetitions in the pattern, for example {4} will match any number of exactly four figures. It also allows setting options, for example {3,6} identifies 5 or 6 digit numbers in the pattern.

() parentheses

When the parentheses in RegEx surround some characters, they serve -as a variable- to store that text enclosed in the parentheses and use it later.

| The vertical bar (also called “pipe”)

Used to toggle various options. Use it like when you want it to be “this or this”.

Practical examples of Google regular expressions

As we have mentioned before, use the Google regular expressions or RegEx it can be tricky at first. That’s why, from Here are some practical examples so you can start using them right away:

Find the match with an IP address

The problem with identifying IP addresses is that they use the dot, and this is the most powerful wildcard; so if we want to match the specific address 192.168.1.1we’ll need to use the regular expression 192\.168\.1\.1 in the filter (if you didn’t, you might as well get values ​​like 192×16831.1).

See also  Quality Score in Google Ads: Why it matters and what to do to improve it -

If you want to filter a range of addresses, you can use 129\.168\.1\.1, for values ​​like 192.168.1.10 either 192.168.1.19etc.

Find the match to a directory name

In a URL, the folder delimiter is the forward slash or slash (/); For example, if we want to see the pageviews of the “communication” directory, we will use the following RegEx .+?/communication/.+? (The use of + means that we want there to be “something” before and after, because if we use .* it could give errors when returning the word alone.

Find the match of a variable in a URL

When friendly URLs are not used, as in many catalogs, it is easy to find the use of variables in the URLs. For example: for something like http://www.unaweb.es/index.php?ID=34 we can use ID=(\d+).

Ultimately, the regular expressions They are used to detect words or numbers that may be an error in the internal SEO of a website. In addition, with them it is possible to know crucial elements for positioning, such as how many links a page has and what its anchor text is (the words in which they are anchored).

At we know the importance of using regular expressions from Google. Contact us if you want more information.

Loading Facebook Comments ...
Loading Disqus Comments ...