Using Regular Expressions to analyze your competitor’s anchors

Your competitors might be using a different keyword strategy than you are. How can you find out what they are doing?

Regular expressions allow you to search the text for patterns. This means that you can easily see if someone else has been copying your content without even having to read their posts!

I did this myself when I had to look through one of my client’s competitors. 

In this particular case, it was a porn site and the client wanted to know what his competitors were doing for the anchor porn hd.

Since I have some experience in this I will demonstrate how you can use regular expressions to see who is stealing your content and what keywords they are targeting.

I’m sure by now you’ve heard of regular expressions. If you haven’t, they’re basically a set of rules used to match patterns within strings of text. 

They’re often used to validate data before inserting it into databases or even parsing through files.

In this post, I’ll walk you through how to use regular expressions to help you analyze your competitors.

Better understanding Regular Expressions

A Regular Expression is a representation for finding patterns in text.

This text can be anything from the value of a form field or simply a search in your favorite code editor.

The goal is to filter out patterns in a handful of textual information.

If you understand that a Regular Expression is just a representation made up of symbols, you will have no difficulties.

Each symbol represents one type of information. For example: the . (dot) is a wildcard. It means that you can select any character, i.e. any letter, special character, or number.

Except for the line break, which is represented by the symbol \n.

Creating our first regex

Using javascript we can choose between two ways of creating a regex. We can create it using a constructor:

const regex = new RegExp(‘dog’,’gi’);
Or by creating it literally:
const regex = /dog/gi

We can search for only one letter:

pattern: /a/
string: The house is clean.
matches: ^

Or we can search for a word:

pattern: /cellular/
string: The cell phone is ringing.
matches: ^^^^^^^
We can see that in the first regex it ignored the first A. This is because regex are case sensitive.
We also notice in the first regex that there was only a match on the first occurrence. To deal with this we will use flags.


These add additional behavior to our rules, such as:
g – indicate find all occurrences of the regex
i – ignore case sensitive
m – multiline, handles start and stop characters (^ and $) when operating on multiple lines.

We can then get all occurrences with the g flag and together with the i flag we can ignore the case sensitive of a search:

pattern: /yesterday/gi
string: Yesterday there was no water, The day before yesterday there was no light
matches:^^^^^ ^^^^^