Academy:

RegEx 101: Ultimate Guide to RegEx for Content Marketers

Read Time: 4 minutes
Last updated: January 24, 2023
Quick Navigation

Last Updated Date

January 24, 2023

Summary

– Understand what RegEx is
– Learn the common RegEx to use to supercharge your sheets workflows
– Practical examples and everyday uses for content marketers.

Quick Navigation

What is RegEx?

Regular Expression, or RegEx as it is commonly called, is a sequence of characters that specifies a search pattern in the text.

RegEx has been around since the 1950s. What number is to maths is what RegEx is to text as it describes a sequence of characters that describes text. 

Where Can I Use RegEx? 5 Places You Can Use RegEx

There are many ways and places you can use RegEx as a marketer. However, the most commonly used places/scenario are:

  • Google sheets
  • Google search console
  • Google Analytics
  • Looker Data Studio
  • Screaming Frog

Where you can use RegEx with Google Sheets

If you are comfortable with Google sheets, there are three Google sheet RegEx formulas you can use

  • REGEXEXTRACT will extract text that matches the pattern.
  • REGEXMATCH will confirm whether it finds the pattern in the text.
  • REGEXREPLACE will replace text that matches the pattern.
Regex in Google Sheets
Regex in Google Sheets

Where you can use RegEx with Google Search Console

Here is one example of where a regular expression can be inputted to show a specific result in Google Search Console. In this example, we can choose to show only queries that do match our regular expressions or that do not match the regular expression.

1: Go to Google search console

2: Navigate to the Performance Report

3: Click the +

4: Select Queries – Custom (Regex) – Matches regex

Regex in Google Search Console
Regex in Google Search Console

Where you can use RegEx with Google Analytics

Regular expressions can be helpful in Google Analytics as they allow you to customize or segment your data. Using regex code, you can include or exclude data within the report.

For example, using a regular expression, we can filter our acquisition report to include only data where the source/medium matches LinkedIn or Facebook

1: Navigate to Acquisition Report

2: Click All Traffic

3: Click Source/Medium

4: Click Advanced

Another use case within Google Analytics is when using filters. In the second example, you can use regular expressions to filter campaign sources matching your regex code.

In this example, we want to include only traffic sources from Facebook.

1: Go to Google Analytics

2: Admin

3: Filter

Regex in Google Analytics
Regex in Google Analytics

Where you can use RegEx with Looker Data Studio

In Looker Data Studio, regular expressions can clean up data, find patterns and automate tasks. 

In this example, we created a case statement in the calculated field to group landing pages by topics to give us a clear picture of our best-performing content.

Regex in Looker Data Studio
Regex in Looker Data Studio

Where you can use RegEx with Screaming Frog

Screaming Frog is a fantastic tool for SEO. We can use Regex to find the information you need in minutes rather than spend hours digging through large amounts of data. In this example, you can for URLs matching your search term in them using the regex .*search_term.*

Regex in Screaming Frog
Regex in Screaming Frog

Why Should You Care About RegEx?

While math is the language of numbers, RegEx is the language of the text. With RegEx, you can speed up/automate workflows such as

  • Content Audits
  • Content grouping
  • Content classification (Funnel Depth Audit)
  • Keyword grouping
  • Keyword extractions
  • Be a more efficient analyst
  • Scripts that work for you = save them, reuse
  • Less analyzing = more time to write/strategize to drive results.

Basic RegEx Every Content Marketer Needs to Know

There are different types of wildcard RegEx you need to know as a beginner. They include

  • ^
  • $
  • *
  • I

Let’s check out what each of them means and how to use it.

RegEx TypeExampleWhat It Means
^^(who|what|where|when|why|how)
“Starts with a question”
          $.* supplies$“Starts with anything, ends with supplies”
..* suppliesMatches any ONE character…The character can be anything
**suppliesMatches the character before 0 or more times
.*.* suppliesThe character before can be there as many times as itlikes (including not at all) AND can be anything…
|(Brand Name|Product 1|Product 2| Product 3)“Match any brand or product name”

Different examples of wildcard RegEx

Example for “^”

^(who|what|where|when|why|how)

What it means: 

“Starts with a question”

Example for $

.* supplies$

What it means:

“Starts with anything, ends with supplies”

Example for “.*”

.*

What it means: 

The character before can be there as many times as it likes (including not at all) AND can be anything…

Example for “*”

Matches the character before 0 or more times

Example for “.*”

.*

What it means:

The character before can be there as many times as it likes (including not at all) AND can be anything…

|

What it means: “This OR That”

Example for “|”

(Brand Name|Product 1|Product 2| Product 3)

What it means: “Match any brand or product name”

How to be efficient with RegEx for faster workflows

Once you create your RegEx, you can reuse it anywhere. Here is an example of how I will use RegEx to extract the domain name from a list of URLs.

Here is an example: =RegExEXTRACT(“https://yourdomain.com”,”^(?:https?:\/\/)?(?:www/\.)?([^\/]+)”)

Saved Regex for Faster Workflows
Saved Regex for Faster Workflows

Useful tools & resources to create, test, and verify RegEx:

Join 25,000+ Marketing Professionals

If you enjoyed this post, please consider subscribing to the Invesp blog feed to have future articles delivered to your feed reader. or,receive weekly updates by email:

Categories of Content

Stay (super) smart, join our weekly letter of news.

No spam. Unsubscribe any time.

Leave a Comment

Your email address will not be published. Required fields are marked *

Meet Ryan

(Your Analytics and CRO Super 🤓)

What most people find incredibly complex (enter: GA4 and sequential testing analysis) Ryan thoroughly enjoys (and is damn good at).

Learn How Rednavel Consulting might be a good fit to help your SaaS or Ecommerce business reach it’s revenue goals.

Apply to work with Rednavel Consulting

Our Assistant, Stringbean