Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
UBC STAT545 2015 cm103: Introduction to Regular...
Search
Kieran Samuk
October 29, 2015
Education
0
970
UBC STAT545 2015 cm103: Introduction to Regular Expressions
One part of a STAT545 lecture from 2015.
Kieran Samuk
October 29, 2015
Tweet
Share
More Decks by Kieran Samuk
See All by Kieran Samuk
Incipient speciation without trophic specialization in the white stickleback
ksamuk
0
35
Natural selection and diversification in the threespine stickleback
ksamuk
0
190
Gene flow favors clustering of adaptive alleles in a globally distributed species
ksamuk
0
82
Other Decks in Education
See All in Education
生成AIとの付き合い方 / Generative AI and us
kaityo256
PRO
10
1.9k
生態系ウォーズ - ルールブック
yui_itoshima
1
300
言葉の文化祭2025:IKIGAI World Fes:program
tsutsumi
1
1k
【ZEPメタバース校舎操作ガイド】
ainischool
0
270
Técnicas y Tecnología para la Investigación Neurocientífica en el Neuromanagement
jvpcubias
0
170
EVOLUCIÓN DE LAS NEUROCIENCIAS EN LOS CONTEXTOS ORGANIZACIONALES
jvpcubias
0
180
[Segah 2025] Gamified Interventions for Composting Behavior in the Workplace
ezefranca
0
190
Alumnote inc. Company Deck
yukinumata
0
4.7k
社外コミュニティの歩き方
masakiokuda
2
210
Linguaxes de programación
irocho
0
290
Avoin jakaminen ja Creative Commons -lisenssit
matleenalaakso
0
2k
AI for Learning
fonylew
0
200
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
369
20k
[RailsConf 2023] Rails as a piece of cake
palkan
57
5.9k
It's Worth the Effort
3n
187
28k
Being A Developer After 40
akosma
91
590k
GitHub's CSS Performance
jonrohan
1032
470k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
Into the Great Unknown - MozCon
thekraken
40
2.1k
The Illustrated Children's Guide to Kubernetes
chrisshort
49
51k
The Language of Interfaces
destraynor
162
25k
Code Reviewing Like a Champion
maltzj
526
40k
A Modern Web Designer's Workflow
chriscoyier
697
190k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Transcript
Regular Expressions & Character Data in R Kieran Samuk for
STAT545
Outline 1. Regular expression basics 2. Regular expressions & character
data in R
Outline 1. Regular expression basics 2. Regular expressions & character
data in R
Regular expressions (“regex”) Coded representations of patterns in text
Regex is (mostly) universal Not limited to a specific programming
language
Insanely useful for… Filtering Finding and replacing Validating input Counting
occurrences Mining text
Regex Anatomy ^[Hh]e walked [0-9]* meters$
Regex Anatomy ^[Hh]e walked [0-9]* meters$ “Literals” “Metacharacters” Normal letters
and digits (+ spaces) Special characters with regex specific functions
Regex Anatomy ^[Hh]e walked [0-9]* meters$ “Literals” “Metacharacters” Normal letters
and digits (+ spaces) Special characters with regex specific functions
Go to https://regex101.com/r/gZ2uW4/2
Literals All literals match themselves, and only themselves
Metacharacters: Groups and Ranges . Any character [AaBb] A or
a or B or b [A-Z] A or B or C, … Z [0-9] 0 or1 or 2, … 9 [^A-Z] Everything but capitals (it|the) “it” OR “the”
Metacharacters: Quantifiers * Zero or more times + One or
more times ? Zero or one times {3} Exactly 3 times {1,3} 1 to 3 times {3,} 3 or more times
Metacharacters: Other ^ Start of a string $ End of
a string \ Escape (meta to literal) \w, \W [A-Za-z0-9], [^A-Za-z0-9] \d, \D [0-9], [^0-9] \s, \S Whitespace (space, tab, newline, carriage return, etc.) + not
Metacharacters: Other ^ Start of a string $ End of
a string \ Escape (meta to literal) \w, \W [A-Za-z0-9], [^A-Za-z0-9] \d, \D [0-9], [^0-9] \s, \S Whitespace (space, tab, newline, carriage return, etc.) + not
Regex Challenges! RULES 1. Match ONLY the target elements 2.
Each discrete item must be a separate match 3. THERE ARE CANDY PRIZES 1. DNA sequences 2. Email addresses 3. Smilies 4. HTML Tags (each tag separately) 5. Phone numbers 6. URLs 7. Macho Man Randy Savage Quotations 9. Citations
Notes Only a glimpse of regex! Lots of resources on
the web
Outline 1. Regular expression basics 2. Regular expressions & character
data in R
Outline 1. Regular expression basics 2. Regular expressions & character
data in R