Regular expressions 101

Nico Brooks

|

October 15, 2020

cat banging on keyboard
Contents

In this video tutorial, we walk through key building blocks of regular expressions using the incredibly powerful REGEXEXTRACT function in Google Sheets. To follow along, make a copy of this Sheet. Topics covered:

  • Matching characters and sets of characters
  • Using ORs to match multiple things
  • Using escapes to match special characters
  • Matching the beginning and end of strings (input text)
  • Extracting substrings with capture groups
  • Bonus: the handy Sheets IFERROR function

A little bit of regex knowledge can go a long way. Regular expressions are supported in all major programming languages, and they are also available as a text/field matching option in many Google products including Analytics, Data Studio, and Tag Manager. For example:

  • Google Analytics
    • View filters
    • Goals – matching pages or event attributes
    • Content groupings
    • Customizing channel groupings
    • Matching dimensions in custom segments
  • Data Studio
    • Filters
    • Custom fields
  • Tag Manager
    • Triggers
    • Custom variables

A few resources mentioned in the video:

  • Regexr – web-based regex testing tool
  • RegexOne – step-by-step regular expression tutorials
  • SEMrush – the source of the sample data in the Sheet, and a fabulous toolset for SEO

And here’s a post I wrote a while back about searching-and-replacing in Sheets with regular expressions.

Share

Picture of Nico Brooks
Nico Brooks
Nico is Two Octobers' Head of Analytics and a co-founder of the agency. He spends most of his time building solutions and finding insights with AI, and has spent 25+ years helping organizations turn marketing data into decisions.

A B2B digital marketing agency that helps lean marketing teams build the strategy and analytics behind sustainable growth.

Subscribe to our newsletter

Explore More Analytics & Marketing Resources Articles

How to Set Up Cloudflare to Block Unwanted Bot Traffic From Your Website and Analytics

Nico Brooks October 26, 2026

Block pesky bot traffic from getting into your Google Analytics data at your CDN. We show you how with Cloudflare's Super Bot Fight Mode.

path through forest in autumn

Analytics Roundup – October 2026

Nico Brooks October 1, 2026

The art of throwing things away; product updates in Google Ads, GA4, Data Studio, GTM; great articles about AI-assisted analysis and data visualization.

purple flowers in sunlight

Analytics Roundup – September 2026

Nico Brooks September 1, 2026

Developing trustworthy architectures for insights with AI; Measurement Protocol replaced by Data Manager; and lots of great analytics & AI articles.