Analytics

Regular expressions 101

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.

Nico Brooks

Nico loves marketing analytics, running, and analytics about running. He's Two Octobers' Head of Analytics, and loves teaching. Learn more about Nico or read more blogs he has written.

Recent Posts

Analytics Roundup – Updates from October 2024

ChatGPT traffic in the GA house! Plus new features in GA4 and understanding GTM first-party…

20 hours ago

GA4 Path Analysis with BigQuery

This article details the process of building two BigQuery tables for path analysis, with a…

4 days ago

Five Great Plug-and-Play SEO Dashboards

Preview five great dashboards for SEO reporting and analysis, and find the one that works…

3 weeks ago