SlideShare a Scribd company logo
@ N a t h a n L e s s | # B r i s t o l S E O
Regular Expressions
For SEO 101
@ N a t h a n L e s s | # B r i s t o l S E O
Why this talk?
Bristol SEO May 2020
@ N a t h a n L e s s | # B r i s t o l S E O
And then this happened…
h t t p s : / / s e a r c h e n g i n e l a n d . c o m / r e g u l a r - e x p r e s s i o n - f i l t e r - s u p p o r t -
c o m i n g - t o - g o o g l e - s e a r c h - c o n s o l e - p e r f o r m a n c e - r e p o r t s - 3 3 7 2 2 4
This means we will be able to easily
segment multiple conditions and brand
and generic performance
@ N a t h a n L e s s | # B r i s t o l S E O
1. Watch the recording of the webinar
2. Use the resources at the end to test
all the examples
3. Use the GA demo account
4. Use the FREE version of Screaming
Frog to filter up to 500 URLs
5. Practice makes purpose
6. Find a Reg Ex buddy
7. Save Reg Ex for later
Tips for Today’s
Webinar
@ N a t h a n L e s s | # B r i s t o l S E O
Match
Extract
Replace
What can
we do with
Reg EX?
@ N a t h a n L e s s | # B r i s t o l S E O
Match
Extract
Replace
What can
we do with
Reg EX?
@ N a t h a n L e s s | # B r i s t o l S E O
Match
Extract
Replace
What can
we do with
Reg EX?
@ N a t h a n L e s s | # B r i s t o l S E O
Match
Extract
Replace
Custom
Extraction
Advanced Filters
Content Groupings
Advanced Filters
Search and Replace Filters
Filtering the Data Table
Advanced Segments
Filters and Goals
Content and Channel
groupings
CrawlConfiguration
Filtering
CrawlConfiguration
REGEXMATCH()
REGEXEXTRACT()
REGEXREPLACE()
REGEXP_MATCH()
REGEXPEXTRACT()
REGEXPREPLACE()
What can
we do with
Reg EX?
@ N a t h a n L e s s | # B r i s t o l S E O
Match
Extract
Replace
Custom
Extraction
Advanced Filters
Content Groupings
Advanced Filters
Search and Replace Filters
Filtering the Data Table
Advanced Segments
Filters and Goals
Content and Channel
groupings
CrawlConfiguration
Filtering
CrawlConfiguration
REGEXMATCH()
REGEXEXTRACT()
REGEXREPLACE()
REGEXP_MATCH()
REGEXPEXTRACT()
REGEXPREPLACE()
What can
we do with
Reg EX?
@ N a t h a n L e s s | # B r i s t o l S E O
What is a Regular Expression?
A regular expression
(regex) is a sequence of
characters that define a
search pattern.
h t t p s : / / e n . wi k i p e d i a . o r g / w i k i / R e g u l a r _ e x p r e s s i o n
@ N a t h a n L e s s | # B r i s t o l S E O
Regular Expression
jon
@ N a t h a n L e s s | # B r i s t o l S E O
Test String
jonathan
@ N a t h a n L e s s | # B r i s t o l S E O
Match
jonathan
@ N a t h a n L e s s | # B r i s t o l S E O
Engine
h t t p s : / / r e g e x 1 0 1 . c o m /
When testing regex double check:
1) The “Flavour”: RE2 = Golang
2) Flags: Global, Multiline and
insensitive
Google products use the RE2 engine.
But there are some quirks, with Sheets
and Data Studio.
@ N a t h a n L e s s | # B r i s t o l S E O
Literal
Characters
12 Meta
Characters
.|()[{^$?*+a-z 0-9 etc
The meta characters are
where the magic happens!
@ N a t h a n L e s s | # B r i s t o l S E O
The Backslash
Use this to escape the
12 meta characters

.html
Most of the time we need to
escape the .?& characters
@ N a t h a n L e s s | # B r i s t o l S E O
InputtingRegExintheGAdataTable
PRO TIP: Save configurations as a Saved Report
?
@ N a t h a n L e s s | # B r i s t o l S E O
The Dot
Matches any single
character
.
.
@ N a t h a n L e s s | # B r i s t o l S E O
The Pipe
Acts like the Boolean OR
|
who|what|when|where|why|how
https://en.wikipedia.org/wiki/Five_Ws
Use this to mine questions
from keyword lists
@ N a t h a n L e s s | # B r i s t o l S E O
The Caret
Matches the beginning of
the string
^
^/products
@ N a t h a n L e s s | # B r i s t o l S E O
The Dollar
Matches the end of the
string
$
^/$
This regular expression
matches the homepage
@ N a t h a n L e s s | # B r i s t o l S E O
The Question
Mark
Matches zero or more
characters
Think of it as optional
?
^https?://www.example.com/
The Question Mark can be
useful for writing expressions
to match brand names
@ N a t h a n L e s s | # B r i s t o l S E O
The Star
Match the last character
0 or more times
When combined with the
dot it becomes a
wildcard and matches
everything
*
^/checkout/.*/thanks
Use the Dot Star combo
when setting up goals
@ N a t h a n L e s s | # B r i s t o l S E O
Parentheses
Use these to group
characters together
Useful for advanced
filters and content
groupings
()
^https://www.apple.com/(befr|benl|lu|nl)/
Grouping characters allows
us to create more complex
patterns and even capture
matches
@ N a t h a n L e s s | # B r i s t o l S E O
Square
Brackets
Use these to match a
specific set or range of
characters
[]
[aeiou]
[a-k]
@ N a t h a n L e s s | # B r i s t o l S E O
Curly Brackets
Quantify how many
characters we need
{}
^/blog/[0-9]{4}/[0-9]{2}
@ N a t h a n L e s s | # B r i s t o l S E O
The Plus
Match the last character
at least once
+
/page/([0-9]+)
@ N a t h a n L e s s | # B r i s t o l S E O
Shorthand
Characters
d matches any digit
/page/([d+)
@ N a t h a n L e s s | # B r i s t o l S E O
b word boundary
.*sbShorthand
Characters
@ N a t h a n L e s s | # B r i s t o l S E O
Screaming Frog uses the Java engine
When testing regex double check:
1) The “Flavour”: JavaScript
2) Flags: Global and Single Line
3) With this engine we need to escape
forward slashes
@ N a t h a n L e s s | # B r i s t o l S E O
Lazy vs Greedy
We can also use the
question mark to make
regex match as few
characters as possible
<p>(.*)</p>
<p>(.*?)</p>
PRO TIP: This pattern is useful
when using custom extraction
in SF
(.*?)
@ N a t h a n L e s s | # B r i s t o l S E O
Thank You
Check out my website
jonathanmoore.digital if you have any
questions or if you want to find out
more about me
Links, glossary and resources are
on next slides
@ N a t h a n L e s s | # B r i s t o l S E O
The Backslash
The Dot
The Pipe
The Carat
The Dollar
The Question
Mark
The Star
Parentheses
Square Brackets
Curly Brackets
The Plus
Any Digit
Shorthand
Word Boundary
Shorthand
Lazy Quantifier
List of Regular
Expressions in
this
Presentation
@ N a t h a n L e s s | # B r i s t o l S E O
Glossary – Part 1 of 2
The Backslash – Escape meta characters
The Dot - Matches any single character
The Pipe – Match either
The Carat - Match beginning of string
The Dollar - Match the end of the string
The Question Mark - Match zero or more characters
The Star - Match the last character 0 or more times

.
|
^
$
?
*
@ N a t h a n L e s s | # B r i s t o l S E O
Glossary – Part 2 of 2
Parenthesis - Group characters together
Square Brackets - Match a specific set of characters
Curly Brackets - Quantify how many characters we need
The Plus - Match the last character at least once
Any Digit Shorthand - Match any digit
Word Boundary Shorthand - Match any word boundary
Lazy Quantifier - Match as few times as possible
()
[]
{}
+
d
w
.*?
@ N a t h a n L e s s | # B r i s t o l S E O
1) Regular Expressions 101
2) Reg Ex for GA Cheat Sheet
3) How to use Reg Ex in GA
4) Reg EX Cheat sheet
5) Google Analytics Demo Account
6) Distilled Guide to REGEX Formulas
in Google Sheets
7) Reg Ex Learning Game
8) RE2 Documentation
Regular
Expression
Resources

More Related Content

PDF
Library Carpentry. Week One: Basics
PDF
Note names part 1 ©
PPTX
Subword tokenizers
PDF
Dynamic links using (meta)data
PDF
Graph Modelling
PPTX
Getting to WordPress
PDF
SQL: The one language to rule all your data
PDF
Predictive analytics: Mining gold and creating valuable product
Library Carpentry. Week One: Basics
Note names part 1 ©
Subword tokenizers
Dynamic links using (meta)data
Graph Modelling
Getting to WordPress
SQL: The one language to rule all your data
Predictive analytics: Mining gold and creating valuable product

Similar to Regular Expressions for SEO (20)

PDF
Regular Expressions in Google Analytics
PPTX
Regular expressions tutorial for SEO & Website Analysis
PDF
GAIQ - Regular expressions-google-analytics
PPTX
Regular Expressions for Regular Joes (and SEOs)
PDF
Regular Expressions For Google Analytics By Robbin Steif
PPT
Regular Expression in Action
PDF
Don't Fear the Regex WordCamp DC 2017
PPTX
Regular Expression Crash Course
PDF
Don't Fear the Regex - Northeast PHP 2015
PDF
Don't Fear the Regex LSP15
PPTX
NUS_NLP__Foundations_-_Section_2_-_Words.pptx
PPTX
Regular expressions
PPT
Introduction to regular expressions
PPTX
Regular Expression (Regex) Fundamentals
PPT
regular-expressions lecture 28-string regular expression
PDF
2013 - Andrei Zmievski: Clínica Regex
KEY
Regular Expressions 101
PPT
2.regular expressions
PPTX
NLP_KASHK:Regular Expressions
PPTX
Introduction to Regular Expressions
Regular Expressions in Google Analytics
Regular expressions tutorial for SEO & Website Analysis
GAIQ - Regular expressions-google-analytics
Regular Expressions for Regular Joes (and SEOs)
Regular Expressions For Google Analytics By Robbin Steif
Regular Expression in Action
Don't Fear the Regex WordCamp DC 2017
Regular Expression Crash Course
Don't Fear the Regex - Northeast PHP 2015
Don't Fear the Regex LSP15
NUS_NLP__Foundations_-_Section_2_-_Words.pptx
Regular expressions
Introduction to regular expressions
Regular Expression (Regex) Fundamentals
regular-expressions lecture 28-string regular expression
2013 - Andrei Zmievski: Clínica Regex
Regular Expressions 101
2.regular expressions
NLP_KASHK:Regular Expressions
Introduction to Regular Expressions
Ad

Recently uploaded (20)

PDF
Mastering the Art of the Prompt - Brantley Smith, HomePro Marketing
PPTX
UNIT 3 - 5 INDUSTRIAL PRICING.ppt x
PPTX
Kimberly Crossland Storytelling Marketing Class 5stars.pptx
PPTX
The evolution of the internet - its impacts on consumers
PPTX
Fixing-AI-Hallucinations-The-NeuroRanktm-Approach.pptx
PDF
EVOLUTION OF RURAL MARKETING IN INDIAN CIVILIZATION
PPTX
Solomon_Chapter 6_The Self: Mind, Gender, and Body.pptx
PDF
UNIT 2 - 5 DISTRIBUTION IN RURAL MARKETS.pdf
PDF
AI & Automation: The Future of Marketing or the End of Creativity - Matthew W...
PDF
How a Travel Company Can Implement Content Marketing
DOCX
AL-ahly Sabbour un official strategic plan.docx
PDF
Proven AI Visibility: From SEO Strategy To GEO Tactics
PDF
AFCAT Syllabus 2026 Guide by Best Defence Academy in Lucknow.pdf
PDF
UNIT 1 -4 Profile of Rural Consumers (1).pdf
PDF
Building a strong social media presence.
PDF
Mastering Bulk Email Campaign Optimization for 2025
PPTX
Amazon - STRATEGIC.......................pptx
DOCX
marketing plan starville............docx
PDF
E_Book_Customer_Relation_Management_0.pdf
PDF
Digital Transformation - Albert Donaldson, Golf Away Tampa Bay
Mastering the Art of the Prompt - Brantley Smith, HomePro Marketing
UNIT 3 - 5 INDUSTRIAL PRICING.ppt x
Kimberly Crossland Storytelling Marketing Class 5stars.pptx
The evolution of the internet - its impacts on consumers
Fixing-AI-Hallucinations-The-NeuroRanktm-Approach.pptx
EVOLUTION OF RURAL MARKETING IN INDIAN CIVILIZATION
Solomon_Chapter 6_The Self: Mind, Gender, and Body.pptx
UNIT 2 - 5 DISTRIBUTION IN RURAL MARKETS.pdf
AI & Automation: The Future of Marketing or the End of Creativity - Matthew W...
How a Travel Company Can Implement Content Marketing
AL-ahly Sabbour un official strategic plan.docx
Proven AI Visibility: From SEO Strategy To GEO Tactics
AFCAT Syllabus 2026 Guide by Best Defence Academy in Lucknow.pdf
UNIT 1 -4 Profile of Rural Consumers (1).pdf
Building a strong social media presence.
Mastering Bulk Email Campaign Optimization for 2025
Amazon - STRATEGIC.......................pptx
marketing plan starville............docx
E_Book_Customer_Relation_Management_0.pdf
Digital Transformation - Albert Donaldson, Golf Away Tampa Bay
Ad

Regular Expressions for SEO

  • 1. @ N a t h a n L e s s | # B r i s t o l S E O Regular Expressions For SEO 101
  • 2. @ N a t h a n L e s s | # B r i s t o l S E O Why this talk? Bristol SEO May 2020
  • 3. @ N a t h a n L e s s | # B r i s t o l S E O And then this happened… h t t p s : / / s e a r c h e n g i n e l a n d . c o m / r e g u l a r - e x p r e s s i o n - f i l t e r - s u p p o r t - c o m i n g - t o - g o o g l e - s e a r c h - c o n s o l e - p e r f o r m a n c e - r e p o r t s - 3 3 7 2 2 4 This means we will be able to easily segment multiple conditions and brand and generic performance
  • 4. @ N a t h a n L e s s | # B r i s t o l S E O 1. Watch the recording of the webinar 2. Use the resources at the end to test all the examples 3. Use the GA demo account 4. Use the FREE version of Screaming Frog to filter up to 500 URLs 5. Practice makes purpose 6. Find a Reg Ex buddy 7. Save Reg Ex for later Tips for Today’s Webinar
  • 5. @ N a t h a n L e s s | # B r i s t o l S E O Match Extract Replace What can we do with Reg EX?
  • 6. @ N a t h a n L e s s | # B r i s t o l S E O Match Extract Replace What can we do with Reg EX?
  • 7. @ N a t h a n L e s s | # B r i s t o l S E O Match Extract Replace What can we do with Reg EX?
  • 8. @ N a t h a n L e s s | # B r i s t o l S E O Match Extract Replace Custom Extraction Advanced Filters Content Groupings Advanced Filters Search and Replace Filters Filtering the Data Table Advanced Segments Filters and Goals Content and Channel groupings CrawlConfiguration Filtering CrawlConfiguration REGEXMATCH() REGEXEXTRACT() REGEXREPLACE() REGEXP_MATCH() REGEXPEXTRACT() REGEXPREPLACE() What can we do with Reg EX?
  • 9. @ N a t h a n L e s s | # B r i s t o l S E O Match Extract Replace Custom Extraction Advanced Filters Content Groupings Advanced Filters Search and Replace Filters Filtering the Data Table Advanced Segments Filters and Goals Content and Channel groupings CrawlConfiguration Filtering CrawlConfiguration REGEXMATCH() REGEXEXTRACT() REGEXREPLACE() REGEXP_MATCH() REGEXPEXTRACT() REGEXPREPLACE() What can we do with Reg EX?
  • 10. @ N a t h a n L e s s | # B r i s t o l S E O What is a Regular Expression? A regular expression (regex) is a sequence of characters that define a search pattern. h t t p s : / / e n . wi k i p e d i a . o r g / w i k i / R e g u l a r _ e x p r e s s i o n
  • 11. @ N a t h a n L e s s | # B r i s t o l S E O Regular Expression jon
  • 12. @ N a t h a n L e s s | # B r i s t o l S E O Test String jonathan
  • 13. @ N a t h a n L e s s | # B r i s t o l S E O Match jonathan
  • 14. @ N a t h a n L e s s | # B r i s t o l S E O Engine h t t p s : / / r e g e x 1 0 1 . c o m / When testing regex double check: 1) The “Flavour”: RE2 = Golang 2) Flags: Global, Multiline and insensitive Google products use the RE2 engine. But there are some quirks, with Sheets and Data Studio.
  • 15. @ N a t h a n L e s s | # B r i s t o l S E O Literal Characters 12 Meta Characters .|()[{^$?*+a-z 0-9 etc The meta characters are where the magic happens!
  • 16. @ N a t h a n L e s s | # B r i s t o l S E O The Backslash Use this to escape the 12 meta characters .html Most of the time we need to escape the .?& characters
  • 17. @ N a t h a n L e s s | # B r i s t o l S E O InputtingRegExintheGAdataTable PRO TIP: Save configurations as a Saved Report ?
  • 18. @ N a t h a n L e s s | # B r i s t o l S E O The Dot Matches any single character . .
  • 19. @ N a t h a n L e s s | # B r i s t o l S E O The Pipe Acts like the Boolean OR | who|what|when|where|why|how https://en.wikipedia.org/wiki/Five_Ws Use this to mine questions from keyword lists
  • 20. @ N a t h a n L e s s | # B r i s t o l S E O The Caret Matches the beginning of the string ^ ^/products
  • 21. @ N a t h a n L e s s | # B r i s t o l S E O The Dollar Matches the end of the string $ ^/$ This regular expression matches the homepage
  • 22. @ N a t h a n L e s s | # B r i s t o l S E O The Question Mark Matches zero or more characters Think of it as optional ? ^https?://www.example.com/ The Question Mark can be useful for writing expressions to match brand names
  • 23. @ N a t h a n L e s s | # B r i s t o l S E O The Star Match the last character 0 or more times When combined with the dot it becomes a wildcard and matches everything * ^/checkout/.*/thanks Use the Dot Star combo when setting up goals
  • 24. @ N a t h a n L e s s | # B r i s t o l S E O Parentheses Use these to group characters together Useful for advanced filters and content groupings () ^https://www.apple.com/(befr|benl|lu|nl)/ Grouping characters allows us to create more complex patterns and even capture matches
  • 25. @ N a t h a n L e s s | # B r i s t o l S E O Square Brackets Use these to match a specific set or range of characters [] [aeiou] [a-k]
  • 26. @ N a t h a n L e s s | # B r i s t o l S E O Curly Brackets Quantify how many characters we need {} ^/blog/[0-9]{4}/[0-9]{2}
  • 27. @ N a t h a n L e s s | # B r i s t o l S E O The Plus Match the last character at least once + /page/([0-9]+)
  • 28. @ N a t h a n L e s s | # B r i s t o l S E O Shorthand Characters d matches any digit /page/([d+)
  • 29. @ N a t h a n L e s s | # B r i s t o l S E O b word boundary .*sbShorthand Characters
  • 30. @ N a t h a n L e s s | # B r i s t o l S E O Screaming Frog uses the Java engine When testing regex double check: 1) The “Flavour”: JavaScript 2) Flags: Global and Single Line 3) With this engine we need to escape forward slashes
  • 31. @ N a t h a n L e s s | # B r i s t o l S E O Lazy vs Greedy We can also use the question mark to make regex match as few characters as possible <p>(.*)</p> <p>(.*?)</p> PRO TIP: This pattern is useful when using custom extraction in SF (.*?)
  • 32. @ N a t h a n L e s s | # B r i s t o l S E O Thank You Check out my website jonathanmoore.digital if you have any questions or if you want to find out more about me Links, glossary and resources are on next slides
  • 33. @ N a t h a n L e s s | # B r i s t o l S E O The Backslash The Dot The Pipe The Carat The Dollar The Question Mark The Star Parentheses Square Brackets Curly Brackets The Plus Any Digit Shorthand Word Boundary Shorthand Lazy Quantifier List of Regular Expressions in this Presentation
  • 34. @ N a t h a n L e s s | # B r i s t o l S E O Glossary – Part 1 of 2 The Backslash – Escape meta characters The Dot - Matches any single character The Pipe – Match either The Carat - Match beginning of string The Dollar - Match the end of the string The Question Mark - Match zero or more characters The Star - Match the last character 0 or more times . | ^ $ ? *
  • 35. @ N a t h a n L e s s | # B r i s t o l S E O Glossary – Part 2 of 2 Parenthesis - Group characters together Square Brackets - Match a specific set of characters Curly Brackets - Quantify how many characters we need The Plus - Match the last character at least once Any Digit Shorthand - Match any digit Word Boundary Shorthand - Match any word boundary Lazy Quantifier - Match as few times as possible () [] {} + d w .*?
  • 36. @ N a t h a n L e s s | # B r i s t o l S E O 1) Regular Expressions 101 2) Reg Ex for GA Cheat Sheet 3) How to use Reg Ex in GA 4) Reg EX Cheat sheet 5) Google Analytics Demo Account 6) Distilled Guide to REGEX Formulas in Google Sheets 7) Reg Ex Learning Game 8) RE2 Documentation Regular Expression Resources