Regular Expressions for Regular Joes (and SEOs)

Paul Shapiro
Paul ShapiroHead of SEO, Catalyst
Regular Expressions
for Regular Joes
(and SEOs)
What are regular expressions?
• A regular expression (sometimes referred to as
regex or regexp) is basically find-and-replace
on steroids, an advanced system of matching
text patterns.
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 2
Most Common Example: Google Analytics
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 3
• Using “pipes” to exclude pages with extraneous
symbols attached to the URL, like UTM tracking
parameters.
Where can I use regular expressions?
• Many text editors
– Notepad++ is an awesome one for Windows
• SEO Tools for Excel add-on
– http://nielsbosma.se/projects/seotools/
• Google Docs
– =regexextract() function
– =regexmatch() function
– =regexreplace() function
• Google Analytics
• Screaming Frog
• DeepCrawl
• .htaccess
– RewriteCond
– RewriteRule
• Programming Languages
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 4
RegEx Basics
Each one of these you learn, the more helpful it is.
You don’t have to learn all of them.
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 5
Anchors
• “Anchors” match position in text rather than text
itself:
– ^ (carat) will match the beginning of a line
– $ (dollar sign) will match the end of a line
Example: word word word word
• ^word  will result in “word word word word”
• word$  will result in “word word word word”
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 6
Character Classes
• [ starts a character class
• ] ends a character class
– Any of the characters within [ ] will be matched
Note: ranges like [G-V] (letters g though v) or [1-10] (number 1 through
10) also work.
Example: hnaeyesdtlaeck
• [nedl]  will result in “hnaeyesdtlaeck”
Example: Do you do SEO or SEM?
• SE[OM]  will result in “Do you do SEO or SEM?”
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 7
Miscellaneous Special Characters
• | (pipe) means OR
Example: this or that?
– this|that will result in “this or that?”
• . (period) represents any character (wildcard)
Example: Excuse my French; Detect profanity like
shit, sh#t, or sh!t.
– sh.t will result in “Detect profanity like shit, sh#t, or sh!t.”
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 8
Escaping Characters
There are many characters in regular expressions which
have special meanings, so if you wish to find the literal
characters they must be “escaped” with a backslash
preceding it.
Example: I want to find the period.
– .  I want to find the period.
– If I used just a period without escaping with a backslash:
.  will result in “I want to find the period.”
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 9
Quantifiers
• ? (question mark) means optional. It matches 0 or 1 of the
previous character, essentially making it optional.
Example: is the url http or https?
– https?  will result in “is the url http or https?”
• * (asterisk) means zero or more. It will find 0 or more occurrences
of the previous character.
Example #1: What’s that photo website again? Is it Flickr, Flicker, or Flickeeer?
– Flicke*r  will result in “What’s that photo website again? Is it Flickr, Flicker, or Flickeeer?”
Example #2: hlp help heelp heeeeeeeelp
– he*lp  will result in “hlp help heelp heeeeeeeelp”
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 10
Quantifiers - Continued
• + (plus) means one or more. It will find 1 or more
occurrences of the previous character.
Example #1: hlp help heelp heeeeeeeelp
– he+lp  will result in “hlp help heelp heeeeeeeelp”
Example #2: hlp help heelp heeeeeeeelp hellllllllp
• h.+lp  will result in “hlp help heelp heeeeeeeelp
hellllllllp”
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 11
Understanding Differences Between Quantifiers
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 12
Animated GIF Example
Quantifiers - Continued
• { } will match a certain quantity of previous
characters. You can also specify a range, like “1 to
3” or “3 or more” if you include a , (comma) inside
the brackets.
Example #1: buz buzz buzzz buzzzz buzzzzz
– buz{3}  will result in “buz buzz buzzz buzzzz buzzzzz”
Note: {3} reads “exactly 3} in plain english.
– buz{2,4}  will result in “buz buzz buzzz buzzzz buzzzzz”
Note: {2,4} reads “2 to 4” in plain english.
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 13
Groups
• Groups are encapsulated in parenthesis ( )
Example: hahaha haha ha haha ha!
– (ha)+  will render “hahaha haha ha haha ha!”
( )COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 14
Capture Groups
• Groups can also be easily captured as variables that
can be repeated back:
– $1 would display the contents of the first group, $2 would
display the contents of the second group and so on.
Example: hello I am paul
– hello I am (.+)  used with $1  will capture “paul”
• To disable the capturing of groups we use (?:), so that they
can be used solely for the purpose of grouping patterns together.
So with the above example, (?:.+) will not capture anything
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 15
Lookarounds
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 16
• Positive Lookaheads will match a group after the main pattern
without actually including it in the result. The expression is
(?=)
Example: 1in 250px 2in 3em 40px
– [0-9]+(?=px)  will result in “1in 250px 2in 3em 40px”
Everything WITH “px”
• A Negative Lookahead is used to specify a group that won’t
be matched after the main pattern. The expression is (?!)
Example: 1in 250px 2in 3em 40px
– [0-9]+(?!em)  will result in “1in 250px 2in 3em 40px”
Everything BUT “em”
RegEx in Practice
Real Use Cases
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 17
Problem #1
I want to take a list of >2,000 Mashable.com URLs,
exported from BuzzSumo.com and segment the
<titles> into different segments (list posts, title as a
question, etc.) and see which ones received a
greater number of social shares.
What is the fastest way of doing this?
Hint:
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 18
Solution #1: SEO Tools for Excel Add-on w/ RegEx
• Is the post title a question?
– =RegexpIsMatch(A2,"?$")
• Is the post a listacle/list post?
– =RegexpIsMatch(A2,"^[0-9]*s|^[0-9],[0-9]*s")
• Extract publishing year from URL
– =RegexpFind(D2,"https?://(?:www.)?mashable.com/([0-
9]{4})/.+","$1")
• Presence of a year in the title
– =IFERROR(RegexpFind(A40,"([0-9]{4})","$1"),“N/A")
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 19
Nice! Took < 1 Minute.
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 20
Problem #2
• There are hundreds of pages with <span> tags
that should be rendered as <h2>. Some have
class and/or id attributes and some don’t. I want
to grab the contents (only) of these span tags for
a client.
What is the fastest way?
…RegEx!
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 21
Solution #2: SEO Tools for Excel Add-on w/ RegEx
• For a list of URL in Excel, and again with the SEO
Tool for Excel add-on, use a regular expression
like this:
– =RegexpFindOnUrl(D3,"<span(?:.+)?>(.+)</span>",1)
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 22
Problem #3:
• I want to grab the full description from a long list of
YouTube videos. We can grab it from the meta
description, but it might be an incomplete
description that is truncated, so we need to grab
the actual page text.
What’s the fastest way?
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 23
…Probably XPath, but we can also use RegEx 
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 24
Solution #3: SEO Tools for Excel Add-on
• For a list of YouTube video URLs in Excel, use the
SEO Tools for Excel Add-on with the following
regular expression:
– =RegexpFindOnUrl(A1,"<p id=.eow-
description.s?>(.+)</p>",1)
Please note, that because the HTML utilized a double-
quote, you have to use another character in its place so as
not to break Excel, like the period, to represent ANY
character.
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 25
Problem #4
• I want to quickly change a long list of keywords
into the exact match format with the keyword
surrounded by brackets, [ ].
What’s the fastest way?
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 26
Solution #4: Notepad++ Example
1. Copy a column of keywords
from Excel into Notepad++
2. Control + F and switch to the
“Replace” tab.
3. Switch the “Search Mode” to
“Regular Expression”
4. Enter ^ in the “Find what” field
and [ in the “Replace with” field.
5. Hit the “Replace All” button.
6. Then, enter $ in the “Find what”
field and ] in the “Replace with”
field.
7. Again, hit the “Replace All”
button.
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 27
Problem #5
• I want to identify which keywords from Google
Webmaster Tools is Branded/Non-
Branded, along with misspellings, from our SQL
database in Spotfire.
What’s the fastest way?
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 28
A Solution: Calculated Column with ~= Operator
• Create a calculated column with an expression
like the below:
If([keyword]~="unstopable|unstopables|unstoppable|unstoppables|inst
opable|instopabales|[ui]nstop[a-z]+?b[a-z]+?s?|(scent booster)|(scent
boosters)",true,false)
– This should find spellings/mis-spellings of Downy Unstopables
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 29
Other Places We Might Use RegEx
Google Analytics supports regular expressions:
– When creating filters
– When setting up goals
– When defining goal funnel steps
– When defining advanced segments
– When using report filters
– When using filters in multichannel reporting
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 30
h/t Annie Cushing
Other Places We Might Use RegEx
.htaccess
– Redirect a set of URLs matching a certain pattern to a new URL
pattern:
Example:
RewriteRule ^/dir/index.php?id=(0-9+).htm$ file-$1 [L]
Screaming Frog
– URL Rewriting: RegEx Replace
– Spider Include/Exclude URLs
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 31
Other Places We Might Use RegEx
Deepcrawl
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 32
Resources
Helpful tool for testing RegEx and gives a good
breakdown of your patterns:
• http://www.regexr.com/
A handy cheat sheet to print and put on your desk:
• http://www.cheatography.com/davechild/cheat-
sheets/regular-expressions/pdf/
SEO Tools for Excel Add-on
• http://nielsbosma.se/projects/seotools/
Notepad++
• http://notepad-plus-plus.org/
COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 33
Thank You!
Paul Shapiro
paul.shapiro@catalystsearchmarketing.com
@fighto
http://blog.paulshapiro.com
1 of 34

Recommended

[LondonSEO 2020] BigQuery & SQL for SEOs by
[LondonSEO 2020] BigQuery & SQL for SEOs[LondonSEO 2020] BigQuery & SQL for SEOs
[LondonSEO 2020] BigQuery & SQL for SEOsAreej AbuAli
6.7K views94 slides
Estrategias SEO en Gestion de Stocks para Ecommerce #CEMD2020 by
Estrategias SEO en Gestion de Stocks para Ecommerce  #CEMD2020Estrategias SEO en Gestion de Stocks para Ecommerce  #CEMD2020
Estrategias SEO en Gestion de Stocks para Ecommerce #CEMD2020MJ Cachón Yáñez
1.2K views65 slides
Winning SEO when doing Web Migrations #SEO4Life by
Winning SEO when doing Web Migrations #SEO4LifeWinning SEO when doing Web Migrations #SEO4Life
Winning SEO when doing Web Migrations #SEO4LifeAleyda Solís
17K views92 slides
SEO for E-commerce in 2020 - Top Technical SEO Challenges & How to Fix them #... by
SEO for E-commerce in 2020 - Top Technical SEO Challenges & How to Fix them #...SEO for E-commerce in 2020 - Top Technical SEO Challenges & How to Fix them #...
SEO for E-commerce in 2020 - Top Technical SEO Challenges & How to Fix them #...Aleyda Solís
12.2K views74 slides
TechSEO Boost - Apps script for SEOs by
TechSEO Boost - Apps script for SEOsTechSEO Boost - Apps script for SEOs
TechSEO Boost - Apps script for SEOsDavid Sottimano
7.7K views83 slides
When Your Inventory Changes: SEO Tips For Changing Product Pages by
When Your Inventory Changes: SEO Tips For Changing Product Pages       When Your Inventory Changes: SEO Tips For Changing Product Pages
When Your Inventory Changes: SEO Tips For Changing Product Pages Aleyda Solís
7.1K views54 slides

More Related Content

What's hot

Winning SEO when Migrating International Websites #dguconf by
Winning SEO when Migrating International Websites #dguconfWinning SEO when Migrating International Websites #dguconf
Winning SEO when Migrating International Websites #dguconfAleyda Solís
3.4K views81 slides
The Worst Technical SEO Nightmares and How to Avoid Them by
The Worst Technical SEO Nightmares and How to Avoid ThemThe Worst Technical SEO Nightmares and How to Avoid Them
The Worst Technical SEO Nightmares and How to Avoid ThemAleyda Solís
5.4K views89 slides
Cost Effective Multilingual Content Optimization in An International SEO Process by
Cost Effective Multilingual Content Optimization in An International SEO ProcessCost Effective Multilingual Content Optimization in An International SEO Process
Cost Effective Multilingual Content Optimization in An International SEO ProcessAleyda Solís
2.5K views46 slides
No More "It Depends" - Learn to Set your Visual SEO Resources #LondonSEOMeetu... by
No More "It Depends" - Learn to Set your Visual SEO Resources #LondonSEOMeetu...No More "It Depends" - Learn to Set your Visual SEO Resources #LondonSEOMeetu...
No More "It Depends" - Learn to Set your Visual SEO Resources #LondonSEOMeetu...Aleyda Solís
2.9K views70 slides
The 8-Step eCommerce Framework to Elevate Your SEO Game at #WTSFest 2020 by
The 8-Step eCommerce Framework to Elevate Your SEO Game at #WTSFest 2020The 8-Step eCommerce Framework to Elevate Your SEO Game at #WTSFest 2020
The 8-Step eCommerce Framework to Elevate Your SEO Game at #WTSFest 2020Kristina Azarenko
6.4K views93 slides
How Online Stores Can Quickly Build Sub-categories Targeting Long-tail Keywor... by
How Online Stores Can Quickly Build Sub-categories Targeting Long-tail Keywor...How Online Stores Can Quickly Build Sub-categories Targeting Long-tail Keywor...
How Online Stores Can Quickly Build Sub-categories Targeting Long-tail Keywor...Kristina Azarenko
3K views97 slides

What's hot(20)

Winning SEO when Migrating International Websites #dguconf by Aleyda Solís
Winning SEO when Migrating International Websites #dguconfWinning SEO when Migrating International Websites #dguconf
Winning SEO when Migrating International Websites #dguconf
Aleyda Solís3.4K views
The Worst Technical SEO Nightmares and How to Avoid Them by Aleyda Solís
The Worst Technical SEO Nightmares and How to Avoid ThemThe Worst Technical SEO Nightmares and How to Avoid Them
The Worst Technical SEO Nightmares and How to Avoid Them
Aleyda Solís5.4K views
Cost Effective Multilingual Content Optimization in An International SEO Process by Aleyda Solís
Cost Effective Multilingual Content Optimization in An International SEO ProcessCost Effective Multilingual Content Optimization in An International SEO Process
Cost Effective Multilingual Content Optimization in An International SEO Process
Aleyda Solís2.5K views
No More "It Depends" - Learn to Set your Visual SEO Resources #LondonSEOMeetu... by Aleyda Solís
No More "It Depends" - Learn to Set your Visual SEO Resources #LondonSEOMeetu...No More "It Depends" - Learn to Set your Visual SEO Resources #LondonSEOMeetu...
No More "It Depends" - Learn to Set your Visual SEO Resources #LondonSEOMeetu...
Aleyda Solís2.9K views
The 8-Step eCommerce Framework to Elevate Your SEO Game at #WTSFest 2020 by Kristina Azarenko
The 8-Step eCommerce Framework to Elevate Your SEO Game at #WTSFest 2020The 8-Step eCommerce Framework to Elevate Your SEO Game at #WTSFest 2020
The 8-Step eCommerce Framework to Elevate Your SEO Game at #WTSFest 2020
Kristina Azarenko6.4K views
How Online Stores Can Quickly Build Sub-categories Targeting Long-tail Keywor... by Kristina Azarenko
How Online Stores Can Quickly Build Sub-categories Targeting Long-tail Keywor...How Online Stores Can Quickly Build Sub-categories Targeting Long-tail Keywor...
How Online Stores Can Quickly Build Sub-categories Targeting Long-tail Keywor...
SEO Reporting for Success at #FOS22 by Aleyda Solís
SEO Reporting for Success at #FOS22SEO Reporting for Success at #FOS22
SEO Reporting for Success at #FOS22
Aleyda Solís1.1K views
BrightonSEO - Master Crawl Budget Optimization for Enterprise Websites by Manick Bhan
BrightonSEO - Master Crawl Budget Optimization for Enterprise WebsitesBrightonSEO - Master Crawl Budget Optimization for Enterprise Websites
BrightonSEO - Master Crawl Budget Optimization for Enterprise Websites
Manick Bhan2.2K views
eCommerce Internal Linking: Into the Spider-Verse-to-upload.pdf by Kristina Azarenko
eCommerce Internal Linking: Into the Spider-Verse-to-upload.pdfeCommerce Internal Linking: Into the Spider-Verse-to-upload.pdf
eCommerce Internal Linking: Into the Spider-Verse-to-upload.pdf
Kristina Azarenko1.2K views
The most Damaging SEO Mistakes & Issues in 2021 and How to Avoid Them #EngagePDX by Aleyda Solís
The most Damaging SEO Mistakes & Issues in 2021 and How to Avoid Them #EngagePDXThe most Damaging SEO Mistakes & Issues in 2021 and How to Avoid Them #EngagePDX
The most Damaging SEO Mistakes & Issues in 2021 and How to Avoid Them #EngagePDX
Aleyda Solís5K views
How to Develop Successful SEO Reports #SEOKomm by Aleyda Solís
How to Develop Successful SEO Reports #SEOKommHow to Develop Successful SEO Reports #SEOKomm
How to Develop Successful SEO Reports #SEOKomm
Aleyda Solís287 views
7 E-Commerce SEO Mistakes & How to Fix Them #DeepSEOCon by Aleyda Solís
7 E-Commerce SEO Mistakes & How to Fix Them #DeepSEOCon7 E-Commerce SEO Mistakes & How to Fix Them #DeepSEOCon
7 E-Commerce SEO Mistakes & How to Fix Them #DeepSEOCon
Aleyda Solís2.4K views
SEO for Changing E-commerce Product Pages - How to Optimize your Online Store... by Aleyda Solís
SEO for Changing E-commerce Product Pages - How to Optimize your Online Store...SEO for Changing E-commerce Product Pages - How to Optimize your Online Store...
SEO for Changing E-commerce Product Pages - How to Optimize your Online Store...
Aleyda Solís1.9K views
Intent-Based International Keyword Research - International Search Summit, Ba... by LazarinaStoyanova
Intent-Based International Keyword Research - International Search Summit, Ba...Intent-Based International Keyword Research - International Search Summit, Ba...
Intent-Based International Keyword Research - International Search Summit, Ba...
LazarinaStoyanova2.3K views
Agile SEO: Prioritise SEO Activities with Cadence and Risk Radius by Parth Suba
Agile SEO: Prioritise SEO Activities with Cadence and Risk RadiusAgile SEO: Prioritise SEO Activities with Cadence and Risk Radius
Agile SEO: Prioritise SEO Activities with Cadence and Risk Radius
Parth Suba1.1K views
Make SEO Audits that Matter & Get Implemented for Success by Aleyda Solís
Make SEO Audits that Matter & Get Implemented for SuccessMake SEO Audits that Matter & Get Implemented for Success
Make SEO Audits that Matter & Get Implemented for Success
Aleyda Solís450 views
How to leverage indexation tracking to monitor issues and improve performance by Simon Lesser
How to leverage indexation tracking to monitor issues and improve performanceHow to leverage indexation tracking to monitor issues and improve performance
How to leverage indexation tracking to monitor issues and improve performance
Simon Lesser682 views
Winning SEO when doing Web Migrations #SMSSYD19 by Aleyda Solís
Winning SEO when doing Web Migrations #SMSSYD19Winning SEO when doing Web Migrations #SMSSYD19
Winning SEO when doing Web Migrations #SMSSYD19
Aleyda Solís6.9K views

Viewers also liked

Export all the data! Rapporti avanzati per SEO e PPC by
Export all the data! Rapporti avanzati per SEO e PPCExport all the data! Rapporti avanzati per SEO e PPC
Export all the data! Rapporti avanzati per SEO e PPCMartino Mosna
404 views45 slides
Getting the right mix of digital analytics tracking, processes and tools by
Getting the right mix of digital analytics tracking, processes and toolsGetting the right mix of digital analytics tracking, processes and tools
Getting the right mix of digital analytics tracking, processes and toolsDigital Science Consulting Ltd
911 views16 slides
Measuring Content Performance - Jon Hibbitt by
Measuring Content Performance - Jon HibbittMeasuring Content Performance - Jon Hibbitt
Measuring Content Performance - Jon HibbittSiteVisibility
9K views78 slides
Fátima Martinez: Usos avanzados del Social Intelligence en The Inbounder Worl... by
Fátima Martinez: Usos avanzados del Social Intelligence en The Inbounder Worl...Fátima Martinez: Usos avanzados del Social Intelligence en The Inbounder Worl...
Fátima Martinez: Usos avanzados del Social Intelligence en The Inbounder Worl...We Are Marketing
2.1K views33 slides
Rafael Jiménez: Attribution Modelings - Edición para technical marketers en T... by
Rafael Jiménez: Attribution Modelings - Edición para technical marketers en T...Rafael Jiménez: Attribution Modelings - Edición para technical marketers en T...
Rafael Jiménez: Attribution Modelings - Edición para technical marketers en T...We Are Marketing
1.9K views74 slides
Fernando Macià: SEO internacional en escenarios complejos en The Inbounder Wo... by
Fernando Macià: SEO internacional en escenarios complejos en The Inbounder Wo...Fernando Macià: SEO internacional en escenarios complejos en The Inbounder Wo...
Fernando Macià: SEO internacional en escenarios complejos en The Inbounder Wo...We Are Marketing
2.1K views105 slides

Viewers also liked(15)

Export all the data! Rapporti avanzati per SEO e PPC by Martino Mosna
Export all the data! Rapporti avanzati per SEO e PPCExport all the data! Rapporti avanzati per SEO e PPC
Export all the data! Rapporti avanzati per SEO e PPC
Martino Mosna404 views
Measuring Content Performance - Jon Hibbitt by SiteVisibility
Measuring Content Performance - Jon HibbittMeasuring Content Performance - Jon Hibbitt
Measuring Content Performance - Jon Hibbitt
SiteVisibility9K views
Fátima Martinez: Usos avanzados del Social Intelligence en The Inbounder Worl... by We Are Marketing
Fátima Martinez: Usos avanzados del Social Intelligence en The Inbounder Worl...Fátima Martinez: Usos avanzados del Social Intelligence en The Inbounder Worl...
Fátima Martinez: Usos avanzados del Social Intelligence en The Inbounder Worl...
We Are Marketing2.1K views
Rafael Jiménez: Attribution Modelings - Edición para technical marketers en T... by We Are Marketing
Rafael Jiménez: Attribution Modelings - Edición para technical marketers en T...Rafael Jiménez: Attribution Modelings - Edición para technical marketers en T...
Rafael Jiménez: Attribution Modelings - Edición para technical marketers en T...
We Are Marketing1.9K views
Fernando Macià: SEO internacional en escenarios complejos en The Inbounder Wo... by We Are Marketing
Fernando Macià: SEO internacional en escenarios complejos en The Inbounder Wo...Fernando Macià: SEO internacional en escenarios complejos en The Inbounder Wo...
Fernando Macià: SEO internacional en escenarios complejos en The Inbounder Wo...
We Are Marketing2.1K views
María José Cachón: Best tools y prácticas para diagnosticar y solucionar prob... by We Are Marketing
María José Cachón: Best tools y prácticas para diagnosticar y solucionar prob...María José Cachón: Best tools y prácticas para diagnosticar y solucionar prob...
María José Cachón: Best tools y prácticas para diagnosticar y solucionar prob...
We Are Marketing2.5K views
Charo Paredes: Cómo optimizar tu APP con un presupuesto limitado en The Inbou... by We Are Marketing
Charo Paredes: Cómo optimizar tu APP con un presupuesto limitado en The Inbou...Charo Paredes: Cómo optimizar tu APP con un presupuesto limitado en The Inbou...
Charo Paredes: Cómo optimizar tu APP con un presupuesto limitado en The Inbou...
We Are Marketing1.9K views
María José Millán: Los 7 pecados capitales del Inbound Marketing en The Inbou... by We Are Marketing
María José Millán: Los 7 pecados capitales del Inbound Marketing en The Inbou...María José Millán: Los 7 pecados capitales del Inbound Marketing en The Inbou...
María José Millán: Los 7 pecados capitales del Inbound Marketing en The Inbou...
We Are Marketing2K views
Aleyda Solis: Reenfocando tu SEO para un mundo Mobile-First by We Are Marketing
Aleyda Solis: Reenfocando tu SEO para un mundo Mobile-FirstAleyda Solis: Reenfocando tu SEO para un mundo Mobile-First
Aleyda Solis: Reenfocando tu SEO para un mundo Mobile-First
We Are Marketing2.1K views
Web Analytics and SEO: Learn the Ropes, Work a Plan, Measure the Right Stuff.... by Brian Alpert
Web Analytics and SEO: Learn the Ropes, Work a Plan, Measure the Right Stuff....Web Analytics and SEO: Learn the Ropes, Work a Plan, Measure the Right Stuff....
Web Analytics and SEO: Learn the Ropes, Work a Plan, Measure the Right Stuff....
Brian Alpert1.1K views
Keyword Research in Autopilot by Google Spreadsheet Macros by Yiğit Konur
Keyword Research in Autopilot by Google Spreadsheet MacrosKeyword Research in Autopilot by Google Spreadsheet Macros
Keyword Research in Autopilot by Google Spreadsheet Macros
Yiğit Konur1.8K views
Turning Analysis into Action with APIs - Superweek 2017 by Peter Meyer
Turning Analysis into Action with APIs - Superweek 2017Turning Analysis into Action with APIs - Superweek 2017
Turning Analysis into Action with APIs - Superweek 2017
Peter Meyer8.2K views

Similar to Regular Expressions for Regular Joes (and SEOs)

Regular Expressions in Google Analytics by
Regular Expressions in Google AnalyticsRegular Expressions in Google Analytics
Regular Expressions in Google AnalyticsShivani Singh
199 views20 slides
Tdd is Dead, Long Live TDD by
Tdd is Dead, Long Live TDDTdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDDJonathan Acker
710 views95 slides
API Simplicity == Speed; Designing APIs That are Easy and Fun to Use by
API Simplicity == Speed; Designing APIs That are Easy and Fun to UseAPI Simplicity == Speed; Designing APIs That are Easy and Fun to Use
API Simplicity == Speed; Designing APIs That are Easy and Fun to UseHarold Madsen
822 views61 slides
Sourcingrecruitinggooglelive by
SourcingrecruitinggoogleliveSourcingrecruitinggooglelive
Sourcingrecruitinggooglelivemgaudet
1.5K views17 slides
Industrial strength - Natural Language Processing by
Industrial strength - Natural Language ProcessingIndustrial strength - Natural Language Processing
Industrial strength - Natural Language ProcessingJeffrey Williams
430 views30 slides
The Road To Damascus - A Conversion Experience: LotusScript and @Formula to SSJS by
The Road To Damascus - A Conversion Experience: LotusScript and @Formula to SSJSThe Road To Damascus - A Conversion Experience: LotusScript and @Formula to SSJS
The Road To Damascus - A Conversion Experience: LotusScript and @Formula to SSJSmfyleman
779 views25 slides

Similar to Regular Expressions for Regular Joes (and SEOs)(20)

Regular Expressions in Google Analytics by Shivani Singh
Regular Expressions in Google AnalyticsRegular Expressions in Google Analytics
Regular Expressions in Google Analytics
Shivani Singh199 views
API Simplicity == Speed; Designing APIs That are Easy and Fun to Use by Harold Madsen
API Simplicity == Speed; Designing APIs That are Easy and Fun to UseAPI Simplicity == Speed; Designing APIs That are Easy and Fun to Use
API Simplicity == Speed; Designing APIs That are Easy and Fun to Use
Harold Madsen822 views
Sourcingrecruitinggooglelive by mgaudet
SourcingrecruitinggoogleliveSourcingrecruitinggooglelive
Sourcingrecruitinggooglelive
mgaudet1.5K views
Industrial strength - Natural Language Processing by Jeffrey Williams
Industrial strength - Natural Language ProcessingIndustrial strength - Natural Language Processing
Industrial strength - Natural Language Processing
Jeffrey Williams430 views
The Road To Damascus - A Conversion Experience: LotusScript and @Formula to SSJS by mfyleman
The Road To Damascus - A Conversion Experience: LotusScript and @Formula to SSJSThe Road To Damascus - A Conversion Experience: LotusScript and @Formula to SSJS
The Road To Damascus - A Conversion Experience: LotusScript and @Formula to SSJS
mfyleman779 views
Practical Machine Learning and Rails Part2 by ryanstout
Practical Machine Learning and Rails Part2Practical Machine Learning and Rails Part2
Practical Machine Learning and Rails Part2
ryanstout1.4K views
What's new for Text in SAP HANA SPS 11 by SAP Technology
What's new for Text in SAP HANA SPS 11What's new for Text in SAP HANA SPS 11
What's new for Text in SAP HANA SPS 11
SAP Technology2K views
DDD patterns that were not in the book by Cyrille Martraire
DDD patterns that were not in the bookDDD patterns that were not in the book
DDD patterns that were not in the book
Cyrille Martraire5.3K views
Google Search by jjs1981
Google SearchGoogle Search
Google Search
jjs19811.4K views
Get the Look and Feel You Want in Oracle APEX by Jorge Rimblas
Get the Look and Feel You Want in Oracle APEXGet the Look and Feel You Want in Oracle APEX
Get the Look and Feel You Want in Oracle APEX
Jorge Rimblas7.3K views
Don't Fear the Regex - CapitalCamp/GovDays 2014 by Sandy Smith
Don't Fear the Regex - CapitalCamp/GovDays 2014Don't Fear the Regex - CapitalCamp/GovDays 2014
Don't Fear the Regex - CapitalCamp/GovDays 2014
Sandy Smith1.1K views
Advanced Search: WebSearch University 2014 by notess
Advanced Search: WebSearch University 2014Advanced Search: WebSearch University 2014
Advanced Search: WebSearch University 2014
notess769 views
Advanced sass/compass by Nick Cooley
Advanced sass/compassAdvanced sass/compass
Advanced sass/compass
Nick Cooley6.1K views
Word embeddings as a service - PyData NYC 2015 by François Scharffe
Word embeddings as a service -  PyData NYC 2015Word embeddings as a service -  PyData NYC 2015
Word embeddings as a service - PyData NYC 2015
François Scharffe2.5K views
Masterclass: How to Research and Build a Query by Brandwatch
Masterclass: How to Research and Build a QueryMasterclass: How to Research and Build a Query
Masterclass: How to Research and Build a Query
Brandwatch3.1K views

More from Paul Shapiro

Breaking Down NLP for SEOs - SMX Advanced Europe 2019 - Paul Shapiro by
Breaking Down NLP for SEOs - SMX Advanced Europe 2019 - Paul ShapiroBreaking Down NLP for SEOs - SMX Advanced Europe 2019 - Paul Shapiro
Breaking Down NLP for SEOs - SMX Advanced Europe 2019 - Paul ShapiroPaul Shapiro
2.1K views55 slides
Redefining Technical SEO, #MozCon 2019 by Paul Shapiro by
Redefining Technical SEO, #MozCon 2019 by Paul ShapiroRedefining Technical SEO, #MozCon 2019 by Paul Shapiro
Redefining Technical SEO, #MozCon 2019 by Paul ShapiroPaul Shapiro
17.4K views89 slides
How to Leverage APIs for SEO #TTTLive2019 by
How to Leverage APIs for SEO #TTTLive2019How to Leverage APIs for SEO #TTTLive2019
How to Leverage APIs for SEO #TTTLive2019Paul Shapiro
3.4K views57 slides
Start Building SEO Efficiencies with Automation - MNSearch Summit 2018 by
Start Building SEO Efficiencies with Automation - MNSearch Summit 2018Start Building SEO Efficiencies with Automation - MNSearch Summit 2018
Start Building SEO Efficiencies with Automation - MNSearch Summit 2018Paul Shapiro
2.8K views74 slides
Put Your Data To Work: Ways to Uncover Content Ideas That Deliver #Confluence... by
Put Your Data To Work: Ways to Uncover Content Ideas That Deliver #Confluence...Put Your Data To Work: Ways to Uncover Content Ideas That Deliver #Confluence...
Put Your Data To Work: Ways to Uncover Content Ideas That Deliver #Confluence...Paul Shapiro
2K views58 slides
The Actionable Guide to Doing Better Semantic Keyword Research #BrightonSEO (... by
The Actionable Guide to Doing Better Semantic Keyword Research #BrightonSEO (...The Actionable Guide to Doing Better Semantic Keyword Research #BrightonSEO (...
The Actionable Guide to Doing Better Semantic Keyword Research #BrightonSEO (...Paul Shapiro
80.7K views50 slides

More from Paul Shapiro(8)

Breaking Down NLP for SEOs - SMX Advanced Europe 2019 - Paul Shapiro by Paul Shapiro
Breaking Down NLP for SEOs - SMX Advanced Europe 2019 - Paul ShapiroBreaking Down NLP for SEOs - SMX Advanced Europe 2019 - Paul Shapiro
Breaking Down NLP for SEOs - SMX Advanced Europe 2019 - Paul Shapiro
Paul Shapiro2.1K views
Redefining Technical SEO, #MozCon 2019 by Paul Shapiro by Paul Shapiro
Redefining Technical SEO, #MozCon 2019 by Paul ShapiroRedefining Technical SEO, #MozCon 2019 by Paul Shapiro
Redefining Technical SEO, #MozCon 2019 by Paul Shapiro
Paul Shapiro17.4K views
How to Leverage APIs for SEO #TTTLive2019 by Paul Shapiro
How to Leverage APIs for SEO #TTTLive2019How to Leverage APIs for SEO #TTTLive2019
How to Leverage APIs for SEO #TTTLive2019
Paul Shapiro3.4K views
Start Building SEO Efficiencies with Automation - MNSearch Summit 2018 by Paul Shapiro
Start Building SEO Efficiencies with Automation - MNSearch Summit 2018Start Building SEO Efficiencies with Automation - MNSearch Summit 2018
Start Building SEO Efficiencies with Automation - MNSearch Summit 2018
Paul Shapiro2.8K views
Put Your Data To Work: Ways to Uncover Content Ideas That Deliver #Confluence... by Paul Shapiro
Put Your Data To Work: Ways to Uncover Content Ideas That Deliver #Confluence...Put Your Data To Work: Ways to Uncover Content Ideas That Deliver #Confluence...
Put Your Data To Work: Ways to Uncover Content Ideas That Deliver #Confluence...
Paul Shapiro2K views
The Actionable Guide to Doing Better Semantic Keyword Research #BrightonSEO (... by Paul Shapiro
The Actionable Guide to Doing Better Semantic Keyword Research #BrightonSEO (...The Actionable Guide to Doing Better Semantic Keyword Research #BrightonSEO (...
The Actionable Guide to Doing Better Semantic Keyword Research #BrightonSEO (...
Paul Shapiro80.7K views
Idea: Selling Clients Google+ Through YouTube by Paul Shapiro
Idea: Selling Clients Google+ Through YouTubeIdea: Selling Clients Google+ Through YouTube
Idea: Selling Clients Google+ Through YouTube
Paul Shapiro1.2K views
Social-SEO Content Strategy: Ideas for a Data Driven Approach by Paul Shapiro
Social-SEO Content Strategy: Ideas for a Data Driven ApproachSocial-SEO Content Strategy: Ideas for a Data Driven Approach
Social-SEO Content Strategy: Ideas for a Data Driven Approach
Paul Shapiro4.1K views

Recently uploaded

AI + Marketing Trends 2024 by
AI + Marketing Trends 2024  AI + Marketing Trends 2024
AI + Marketing Trends 2024 Antony Mayfield
8 views9 slides
Matthew-case-study-v2.pdf by
Matthew-case-study-v2.pdfMatthew-case-study-v2.pdf
Matthew-case-study-v2.pdfkowsikpirabhusr1
22 views23 slides
Weekly Media Update_04_12_2023.pdf by
Weekly Media Update_04_12_2023.pdfWeekly Media Update_04_12_2023.pdf
Weekly Media Update_04_12_2023.pdfBalmerLawrie
14 views6 slides
GDPR Compliant Growth Hacks (TheBootstrappedWay.com) by
GDPR Compliant Growth Hacks (TheBootstrappedWay.com)GDPR Compliant Growth Hacks (TheBootstrappedWay.com)
GDPR Compliant Growth Hacks (TheBootstrappedWay.com)Daniel Pirciu
5 views48 slides
digital marketing ppt.pptx by
digital marketing ppt.pptxdigital marketing ppt.pptx
digital marketing ppt.pptxsurendraswami7172
25 views13 slides
this is superops_v5.pdf by
this is superops_v5.pdfthis is superops_v5.pdf
this is superops_v5.pdfkowsikpirabhusr1
30 views27 slides

Recently uploaded(20)

Weekly Media Update_04_12_2023.pdf by BalmerLawrie
Weekly Media Update_04_12_2023.pdfWeekly Media Update_04_12_2023.pdf
Weekly Media Update_04_12_2023.pdf
BalmerLawrie14 views
GDPR Compliant Growth Hacks (TheBootstrappedWay.com) by Daniel Pirciu
GDPR Compliant Growth Hacks (TheBootstrappedWay.com)GDPR Compliant Growth Hacks (TheBootstrappedWay.com)
GDPR Compliant Growth Hacks (TheBootstrappedWay.com)
Daniel Pirciu5 views
"SEO Mastery: Top 10 Tools used by every expert for improving Websites" by Beacon Coders
 "SEO Mastery: Top 10 Tools used by every expert for improving Websites" "SEO Mastery: Top 10 Tools used by every expert for improving Websites"
"SEO Mastery: Top 10 Tools used by every expert for improving Websites"
Beacon Coders7 views
How to create and present logo. pdf by Gaurav Singh
How to create and present logo. pdfHow to create and present logo. pdf
How to create and present logo. pdf
Gaurav Singh22 views
Marketing Stories 2023 - Year in Review.pdf by Digital Uncovered
Marketing Stories 2023 - Year in Review.pdfMarketing Stories 2023 - Year in Review.pdf
Marketing Stories 2023 - Year in Review.pdf
7 Benefits of Child Welfare Management Software by jeremyray18
7 Benefits of Child Welfare Management Software7 Benefits of Child Welfare Management Software
7 Benefits of Child Welfare Management Software
jeremyray188 views
content strategy _ seconed oponion _medical industry by jonathanhany42
content strategy _ seconed oponion _medical industrycontent strategy _ seconed oponion _medical industry
content strategy _ seconed oponion _medical industry
jonathanhany4213 views
The Canvas of Creative Mastery Newsletter_November 2023 by AmirYakdi
The Canvas of Creative Mastery Newsletter_November 2023The Canvas of Creative Mastery Newsletter_November 2023
The Canvas of Creative Mastery Newsletter_November 2023
AmirYakdi107 views
"SEO Keyword Checklist: Supercharge Your Website's Ranking Strategy" by Beacon Coders
"SEO Keyword Checklist: Supercharge Your Website's Ranking Strategy""SEO Keyword Checklist: Supercharge Your Website's Ranking Strategy"
"SEO Keyword Checklist: Supercharge Your Website's Ranking Strategy"
Beacon Coders8 views
The evolution of internet.pptx by ssuser520a351
The evolution of internet.pptxThe evolution of internet.pptx
The evolution of internet.pptx
ssuser520a3516 views
November 2023 - Partners meeting group by Vbout.com
November 2023 - Partners meeting groupNovember 2023 - Partners meeting group
November 2023 - Partners meeting group
Vbout.com31 views

Regular Expressions for Regular Joes (and SEOs)

  • 2. What are regular expressions? • A regular expression (sometimes referred to as regex or regexp) is basically find-and-replace on steroids, an advanced system of matching text patterns. COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 2
  • 3. Most Common Example: Google Analytics COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 3 • Using “pipes” to exclude pages with extraneous symbols attached to the URL, like UTM tracking parameters.
  • 4. Where can I use regular expressions? • Many text editors – Notepad++ is an awesome one for Windows • SEO Tools for Excel add-on – http://nielsbosma.se/projects/seotools/ • Google Docs – =regexextract() function – =regexmatch() function – =regexreplace() function • Google Analytics • Screaming Frog • DeepCrawl • .htaccess – RewriteCond – RewriteRule • Programming Languages COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 4
  • 5. RegEx Basics Each one of these you learn, the more helpful it is. You don’t have to learn all of them. COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 5
  • 6. Anchors • “Anchors” match position in text rather than text itself: – ^ (carat) will match the beginning of a line – $ (dollar sign) will match the end of a line Example: word word word word • ^word  will result in “word word word word” • word$  will result in “word word word word” COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 6
  • 7. Character Classes • [ starts a character class • ] ends a character class – Any of the characters within [ ] will be matched Note: ranges like [G-V] (letters g though v) or [1-10] (number 1 through 10) also work. Example: hnaeyesdtlaeck • [nedl]  will result in “hnaeyesdtlaeck” Example: Do you do SEO or SEM? • SE[OM]  will result in “Do you do SEO or SEM?” COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 7
  • 8. Miscellaneous Special Characters • | (pipe) means OR Example: this or that? – this|that will result in “this or that?” • . (period) represents any character (wildcard) Example: Excuse my French; Detect profanity like shit, sh#t, or sh!t. – sh.t will result in “Detect profanity like shit, sh#t, or sh!t.” COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 8
  • 9. Escaping Characters There are many characters in regular expressions which have special meanings, so if you wish to find the literal characters they must be “escaped” with a backslash preceding it. Example: I want to find the period. – .  I want to find the period. – If I used just a period without escaping with a backslash: .  will result in “I want to find the period.” COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 9
  • 10. Quantifiers • ? (question mark) means optional. It matches 0 or 1 of the previous character, essentially making it optional. Example: is the url http or https? – https?  will result in “is the url http or https?” • * (asterisk) means zero or more. It will find 0 or more occurrences of the previous character. Example #1: What’s that photo website again? Is it Flickr, Flicker, or Flickeeer? – Flicke*r  will result in “What’s that photo website again? Is it Flickr, Flicker, or Flickeeer?” Example #2: hlp help heelp heeeeeeeelp – he*lp  will result in “hlp help heelp heeeeeeeelp” COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 10
  • 11. Quantifiers - Continued • + (plus) means one or more. It will find 1 or more occurrences of the previous character. Example #1: hlp help heelp heeeeeeeelp – he+lp  will result in “hlp help heelp heeeeeeeelp” Example #2: hlp help heelp heeeeeeeelp hellllllllp • h.+lp  will result in “hlp help heelp heeeeeeeelp hellllllllp” COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 11
  • 12. Understanding Differences Between Quantifiers COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 12 Animated GIF Example
  • 13. Quantifiers - Continued • { } will match a certain quantity of previous characters. You can also specify a range, like “1 to 3” or “3 or more” if you include a , (comma) inside the brackets. Example #1: buz buzz buzzz buzzzz buzzzzz – buz{3}  will result in “buz buzz buzzz buzzzz buzzzzz” Note: {3} reads “exactly 3} in plain english. – buz{2,4}  will result in “buz buzz buzzz buzzzz buzzzzz” Note: {2,4} reads “2 to 4” in plain english. COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 13
  • 14. Groups • Groups are encapsulated in parenthesis ( ) Example: hahaha haha ha haha ha! – (ha)+  will render “hahaha haha ha haha ha!” ( )COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 14
  • 15. Capture Groups • Groups can also be easily captured as variables that can be repeated back: – $1 would display the contents of the first group, $2 would display the contents of the second group and so on. Example: hello I am paul – hello I am (.+)  used with $1  will capture “paul” • To disable the capturing of groups we use (?:), so that they can be used solely for the purpose of grouping patterns together. So with the above example, (?:.+) will not capture anything COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 15
  • 16. Lookarounds COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 16 • Positive Lookaheads will match a group after the main pattern without actually including it in the result. The expression is (?=) Example: 1in 250px 2in 3em 40px – [0-9]+(?=px)  will result in “1in 250px 2in 3em 40px” Everything WITH “px” • A Negative Lookahead is used to specify a group that won’t be matched after the main pattern. The expression is (?!) Example: 1in 250px 2in 3em 40px – [0-9]+(?!em)  will result in “1in 250px 2in 3em 40px” Everything BUT “em”
  • 17. RegEx in Practice Real Use Cases COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 17
  • 18. Problem #1 I want to take a list of >2,000 Mashable.com URLs, exported from BuzzSumo.com and segment the <titles> into different segments (list posts, title as a question, etc.) and see which ones received a greater number of social shares. What is the fastest way of doing this? Hint: COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 18
  • 19. Solution #1: SEO Tools for Excel Add-on w/ RegEx • Is the post title a question? – =RegexpIsMatch(A2,"?$") • Is the post a listacle/list post? – =RegexpIsMatch(A2,"^[0-9]*s|^[0-9],[0-9]*s") • Extract publishing year from URL – =RegexpFind(D2,"https?://(?:www.)?mashable.com/([0- 9]{4})/.+","$1") • Presence of a year in the title – =IFERROR(RegexpFind(A40,"([0-9]{4})","$1"),“N/A") COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 19
  • 20. Nice! Took < 1 Minute. COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 20
  • 21. Problem #2 • There are hundreds of pages with <span> tags that should be rendered as <h2>. Some have class and/or id attributes and some don’t. I want to grab the contents (only) of these span tags for a client. What is the fastest way? …RegEx! COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 21
  • 22. Solution #2: SEO Tools for Excel Add-on w/ RegEx • For a list of URL in Excel, and again with the SEO Tool for Excel add-on, use a regular expression like this: – =RegexpFindOnUrl(D3,"<span(?:.+)?>(.+)</span>",1) COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 22
  • 23. Problem #3: • I want to grab the full description from a long list of YouTube videos. We can grab it from the meta description, but it might be an incomplete description that is truncated, so we need to grab the actual page text. What’s the fastest way? COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 23
  • 24. …Probably XPath, but we can also use RegEx  COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 24
  • 25. Solution #3: SEO Tools for Excel Add-on • For a list of YouTube video URLs in Excel, use the SEO Tools for Excel Add-on with the following regular expression: – =RegexpFindOnUrl(A1,"<p id=.eow- description.s?>(.+)</p>",1) Please note, that because the HTML utilized a double- quote, you have to use another character in its place so as not to break Excel, like the period, to represent ANY character. COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 25
  • 26. Problem #4 • I want to quickly change a long list of keywords into the exact match format with the keyword surrounded by brackets, [ ]. What’s the fastest way? COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 26
  • 27. Solution #4: Notepad++ Example 1. Copy a column of keywords from Excel into Notepad++ 2. Control + F and switch to the “Replace” tab. 3. Switch the “Search Mode” to “Regular Expression” 4. Enter ^ in the “Find what” field and [ in the “Replace with” field. 5. Hit the “Replace All” button. 6. Then, enter $ in the “Find what” field and ] in the “Replace with” field. 7. Again, hit the “Replace All” button. COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 27
  • 28. Problem #5 • I want to identify which keywords from Google Webmaster Tools is Branded/Non- Branded, along with misspellings, from our SQL database in Spotfire. What’s the fastest way? COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 28
  • 29. A Solution: Calculated Column with ~= Operator • Create a calculated column with an expression like the below: If([keyword]~="unstopable|unstopables|unstoppable|unstoppables|inst opable|instopabales|[ui]nstop[a-z]+?b[a-z]+?s?|(scent booster)|(scent boosters)",true,false) – This should find spellings/mis-spellings of Downy Unstopables COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 29
  • 30. Other Places We Might Use RegEx Google Analytics supports regular expressions: – When creating filters – When setting up goals – When defining goal funnel steps – When defining advanced segments – When using report filters – When using filters in multichannel reporting COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 30 h/t Annie Cushing
  • 31. Other Places We Might Use RegEx .htaccess – Redirect a set of URLs matching a certain pattern to a new URL pattern: Example: RewriteRule ^/dir/index.php?id=(0-9+).htm$ file-$1 [L] Screaming Frog – URL Rewriting: RegEx Replace – Spider Include/Exclude URLs COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 31
  • 32. Other Places We Might Use RegEx Deepcrawl COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 32
  • 33. Resources Helpful tool for testing RegEx and gives a good breakdown of your patterns: • http://www.regexr.com/ A handy cheat sheet to print and put on your desk: • http://www.cheatography.com/davechild/cheat- sheets/regular-expressions/pdf/ SEO Tools for Excel Add-on • http://nielsbosma.se/projects/seotools/ Notepad++ • http://notepad-plus-plus.org/ COPYRIGHT 2014 CATALYST. ALL RIGHTS RESERVED. APRIL 29, 2014 | PAGE 33