Connect with us


A Guide To Regular Expressions (With Use Cases)



A Guide To Regular Expressions (With Use Cases)

Perhaps you’ve heard of regex but aren’t quite sure how it can be used in SEO or whether it fits into your own strategy.

Regular expressions, or ‘regex’, are like an in-line programming language for text searches that allow you to include complex search strings, partial matches and wildcards, case-insensitive searches, and other advanced instructions.

You can think of them as searching for a pattern, rather than a specific string of text.

Therefore, they can help you to find entire sets of search results that, at first glance, may appear to have little in common with each other.

Regex expressions are a language all their own and the first time you see one, it can look quite alien.

But they are quite easy to learn and can be used across JavaScript, Python and other programming languages, making them a versatile and powerful SEO tool.

In this guide, you’ll learn common regex operators, how to use more advanced regex filters for SEO, how to use regex in Google Analytics and Google Search Console, and more.


You’ll find examples of regex at work in different ways in SEO, too.

What Does Regex Look Like?

A regular expression typically includes a combination of text that will match exactly in the search results, along with several operators that act more like wildcards to achieve a pattern match rather than an exact text match.

This can include a single-character wildcard, a match for one or more characters, or a match for zero or more characters, as well as optional characters, nested sub-expressions in parentheses, and ‘or’ functions.

By combining these different operations together, you can build a complex expression that can achieve very far-reaching, yet very specific results.

Common Regex Operators

A few examples of common regex operators include:

.         A wildcard match for any single character.

.*       A match for zero or more characters.

.+      A match for one or more characters.


d        A match for any single numerical digit 0-9.

?        Inserted after a character to make it an optional part of the expression.

|        A vertical line or ‘pipe’ character indicates an ‘or’ function.

^       Used to denote the start of a string.

See also  Shopify SEO 2022: The Guide to Optimizing Shopify

$        Used to denote the end of a string.

( )      Used to nest a sub-expression.

        Inserted before an operator or special character to ‘escape’ it.

Some programming languages, such as JavaScript, allow the inclusion of ‘flags’ after the regex pattern itself, and these can further affect the outcome:


g        Returns all matches instead of just the first one.

i         Returns case-insensitive results.

m       Activates multiline mode.

s        Activates ‘dotall’ mode.

u        Activates full Unicode support.

y        Searches the specific text position (‘sticky’ mode).

As you can see, together these operators and flags start to build up to a complex logical language, giving you the ability to achieve very specific results across large, unordered data sets.

How Do You Use Regex For SEO?

Regex can be used to explore the queries different user segments use, which queries are common to specific content areas, which queries drive traffic to specific parts of your site, and more.


In this article, Hamlet Batista demonstrated how to use regex in Python to analyze server log files, for example.

And in this one, Chris Long showed you how to use regex to extract the position, item, and name of the breadcrumbs associated with each URL of your site as part of a scalable keyword research and segmentation process.

Google encourages SEO pros to share examples of how they’re using regex on Twitter using the hashtag #performanceregex.

Here are a couple tips from SEO Twitter (you’ll notice it’s a pretty quiet hashtag – add your own examples if you have them!):

Using Regex On Google Analytics

One of the most common uses of regex for SEO is in Google Analytics, where regular expressions can be used to set up filters so that you only see the data you want to see.


In this sense, the expression is used to exclude results, rather than to generate a set of inclusive search results.

For example, if you want to exclude data from IP addresses on your local area network, you might filter out 192.168.*.* to remove the full range from to

More Advanced Regex SEO Filters

As a more complex example, let’s imagine you have two brands: regex247 and regex365.

You might want to filter results that match any combination of URLs that contain these brand names, such as or

One way to do this is with a fairly simple ‘or’ expression:


This would remove all matching URLs from your Analytics data, including subfolder paths and specific page URLs that appear on those domain names.

A Word Of Warning

It is worth noting that – similar to your robots.txt file – a poorly written regex expression can quite easily filter out most or all of your data by including an unrestricted wildcard match.


The good news is that in many SEO cases, the filter is only applied to your data at the reporting stage, and by editing or deleting your regex expression, you can restore full visibility to your data.

You can also test regular expressions on a number of online testing tools, in order to see if they achieve the intended outcome – allowing you to ‘sandbox’ your regex expressions before you let them loose across your entire data set.

To create regex filters on Google Analytics, first, navigate to the type of Report you want to create (e.g. Behaviour > Site Content > All Pages or Acquisition > All Traffic > Source/Medium).

Below the graph, at the top of the data table, look for the search box and click advanced to display the advanced filter options.

Here you can include or exclude data based on a particular dimension or metric. In the dropdown list after you select your dimension, choose Matching RegExp and then enter your expression into the text box.

‘Or’ And ‘And’ In Google Analytics Regex

To create an ‘or’ expression in Google Analytics, just include the pipe character (the | vertical stroke symbol) between the appropriate segments of your expression.

Google Analytics regular expressions do not support ‘and’ statements within a single regex; however, you can just add another filter to achieve this.

Below your first regex, just click Add a dimension or metric and enter your next regex. In this way, you can stack as many expressions as you want and they will be processed as a single logical ‘and’ statement when filtering your data.


Using Regex In Google Search Console

In 2021, Google Search Console began supporting the Re2 syntax of regex, allowing webmasters to include and exclude data within the user interface.

You’ll find all metacharacters supported by Google Search Console in this RE2 regex syntax reference on GitHub.

At the time of writing, there is a character limit of 4096 characters (which is usually enough…).

Examples you can use in Search Console can be filtering for queries containing a specific brand and the variations users could type, such as Facebook:


Filter out users finding your website through “commercial” intent terms:


Related: Google Search Console Adds New Regex Filter Options


Why Is Regex Important For SEO?

Finally, why does all this matter?

Well, it’s all about taking control of your data and filtering out the parts of it that don’t help you to improve your SEO – whether that’s particular pages or parts of your website, traffic from a specific source or medium, or your own local network data.

You can create quite simple regex expressions to achieve a basic ‘include’ or ‘exclude’ filter, or write longer expressions that work similarly to programming code to achieve complex and very specific results.

And with the right regex for each campaign, you can verify that your SEO efforts are achieving your aims, ambitions, and outcomes – a powerful way to prove positive ROI on your future SEO investments.

More resources:

Featured Image: Optura Design/Shutterstock

fbq('init', '1321385257908563');

fbq('track', 'PageView');

fbq('trackSingle', '1321385257908563', 'ViewContent', { content_name: 'regex-seo-beginners-guide', content_category: 'seo ' });

Source link


How Data Is Reshaping The SEO & Digital Marketer’s Landscape



How Data Is Reshaping The SEO & Digital Marketer's Landscape

There is a new data revolution happening, and it’s sweeping across the industry so quickly that many SEO and digital marketers are struggling to make sense of the insights and intelligence at their disposal.

To utilize this opportunity, marketers need to evolve their mindsets and use technology to analyze multiple data formats and understand the new opportunities it can bring.

SEO marketers of today and digital marketers of tomorrow will need to extract, structure quickly, and manipulate data to drive the most critical business outcomes.

Data has always been mission-critical to digital decision-making.

The Economist, back in 2017, declared it the world’s most valuable resource.

Fast forward to today and the future, and we can see that the exponential growth of data fuelling this revolution is staggering.

According to the IDC, the amount of digital data created over the next five years will be greater than twice the amount of data made since the advent of digital storage.


Think about that for a second!

Flash drives, for example, were introduced in 2000.

This means that in the next five years, marketers will have to analyze and make sense of 2x the data created in the last 22 years!

The Data Revolution Means More Sources & Complexity For SEO

The data revolution has gone on for some time now, and it’s changed our concept of what counts as “data,” rightfully so.

In the past, we thought only numbers mattered.

But, in this new digital world where everything is converted into ones and zeros, data is broader and contains text, audio, and visual information – all bits waiting to be processed!

  • Machine-based and human-generated data are growing at a rate of 10x faster than conventional business data.
  • Machine-created data is increasing exponentially at a 50x the growth rate. This data revolution is primarily marketing-driven and consumer-oriented who are “always on.”
  • In just the last 18 months, the volume of site processing data we have been generating at BrightEdge has increased by 11x!
See also  Payday loans algorithm update 2022

As a result of these increasingly demanding trends, SEO and digital marketers need to adapt and become more like data analysts and scientists in approaching the extraction of structured data insights and business intelligence – without adding more manual work.

Fortunately, SEO is well-positioned to take advantage of this new data revolution.

  • Increasing your keyword universe – More keywords mean more data points to look at with reporting and fuelling insights. While focusing on conversion rate metrics is very important, it wouldn’t be possible without opening the scope of your audience and getting more people in the door. SEO has drifted away from writing for a primary dedicated keyword and is now way more advanced with advancements in search engines like Google’s understanding of intent of searches through RankBrain and BERT.
  • Increasing your search footprint – will also help you discover unexplored of informing your future content strategy or ideate new keyword ideas. However, sometimes you might miss the boat, like the transition of Content Management Systems slowly turning into “Experience Platforms” as they offer more functionality to meet the needs of today’s webmaster or marketer.

Read More On SEJ

Data Is The Currency Of An Accelerated SEO & Digital Age

By 2025, Worldwide data will reach 175 zettabytes.

But unfortunately, the human brain can’t process, structure, and analyze all that data.


So technology engines have to help, and digital marketers should be the driver.

There is a massive opportunity for companies that can utilize data to create more engaging experiences.

A recent study showed that 95% of business leaders recognize this as their biggest growth lever over the next three years, which means there’s plenty at stake here!

See also  7 Things You Need To Know About The Digital Services Act (DSA)

Robust data analysis ensures decisions are evidence-based and have more accountability.

Drawing on existing and new data sources to fully integrate business acumen and analytical skills into decision making, sourcing, managing, and analyzing large amounts of unstructured data will ensure continued use and success.

SEO began with data and has evolved.

From the introduction of real-time SEO in 2019 and Page Experience Updates in 2021, SEO’s future lies again with data and the creation of intelligent systems. Here marketers can leverage combined data sources that structures data for them.

As a result, they can achieve business objectives and stay ahead during all data and digital transformation stages.


Read More On SEJ

Technology & AI Are Helping SEO Evolve

Advancements in technology and, in particular, AI and Natural Language Processing has meant that SEO and digital marketers can become data analysts without having to become an actual data scientist.

This is key to unlocking structured insights from your company’s big data to make more precise predictions about what is coming next based on existing information.

Digital marketers can evolve, understand key trends, and learn in new areas such as:

  • Predictive modeling of future trends and forecasting based on multiple types of data.
  • Real-time identification of opportunities and intelligence.
  • Digital research at scale with both historical and real-time data.
  • Leveraging automated visualizations for various stakeholders.
  • Improved data security and compliance.
  • Market and business intelligence at a macro level.
  • Consumer behavior at the most granular level.

SEO and digital marketers can learn critical skills such as statistics, data analysis, data visualization, and strategy.

See also  Google to Caution Users When its Search Results Are Sub-Standard

AI, NLP, and machine learning are helping them do this without needing expertise in computer programming and software applications.

What digital marketers must do is combine their communication skills and analytics skills with stakeholders who cannot think outside of the advertising box.

Read More On SEJ

Data Analysis & Intelligence As Competitive Advantage

The application of technology will be the driving force behind the next generation of data analysis technology.

Therefore, SEO and digital marketers of today should learn how to better utilize insights from data analysis.

It’s becoming more apparent that the marketing platforms of tomorrow will require the capabilities of data analysis and science infrastructure at their core.


The future of marketing will blend technological know-how, business sense, and an understanding of data analysis.

The next generation of SEO will touch all components of marketing, from video, email, and voice, to digital performance of content.

SEO and data science will converge into one evolved discipline that drives omnichannel acquisition and democratizes data.

Marketers who embrace this new era of SEO will be well-positioned to succeed in the years to come.

Data is reconfirming its role as the new competitive advantage, and as SEO and digital marketers, you must evolve if you want to be part of the future.

More resources:

Featured Image: ra2 studio/Shutterstock



if( typeof sopp !== “undefined” && sopp === ‘yes’ ){
fbq(‘dataProcessingOptions’, [‘LDU’], 1, 1000);
fbq(‘dataProcessingOptions’, []);

fbq(‘init’, ‘1321385257908563’);

fbq(‘track’, ‘PageView’);

fbq(‘trackSingle’, ‘1321385257908563’, ‘ViewContent’, {
content_name: ‘seo-data-and-digital-marketer’,
content_category: ‘trends-digital enterprise’

Source link

Continue Reading

Subscribe To our Newsletter
We promise not to spam you. Unsubscribe at any time.
Invalid email address