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 Expressions
Search
Kieran Samuk
October 29, 2015
Education
0
960
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
25
Natural selection and diversification in the threespine stickleback
ksamuk
0
170
Gene flow favors clustering of adaptive alleles in a globally distributed species
ksamuk
0
47
Other Decks in Education
See All in Education
LightSail2324
cbtlibrary
0
110
全員参加型で会社を強くしていく活動を考えてみる
ikefukurou777
0
160
千葉県印西市立・原山小学校における新たな学び「情報探究の時間」実践報告』
codeforeveryone
1
480
H5P-työkalut
matleenalaakso
3
32k
Canva
matleenalaakso
0
100
【業務イメージスライド】コンサル_メルカリの成長戦略_セナカインターン
cenaka_intern
0
190
RE:HACK 2023 - Reverse Engineering and Binary Exploitation: Intel x86/x86-x64 Assembly
x86fatah
1
180
高可用性システム構築 - Oracle Data Guard基本編
oracle4engineer
PRO
2
650
スクフェスの学びにチームを惹き込め! 社内同時視聴会のすゝめ!
pokotyamu
0
550
Analysis and Validation - Lecture 4 - Information Visualisation (4019538FNR)
signer
PRO
0
1.4k
Padlet opetuksessa
matleenalaakso
3
11k
Monaca Educationを活用した課題解決型の探究学習の実践
asial_edu
0
150
Featured
See All Featured
XXLCSS - How to scale CSS and keep your sanity
sugarenia
240
1.2M
The Mythical Team-Month
searls
214
42k
BBQ
matthewcrist
78
8.7k
Fantastic passwords and where to find them - at NoRuKo
philnash
35
2.4k
Fireside Chat
paigeccino
19
2.6k
Happy Clients
brianwarren
91
6.3k
Ruby is Unlike a Banana
tanoku
95
10k
Optimising Largest Contentful Paint
csswizardry
7
2.3k
Become a Pro
speakerdeck
PRO
8
4.4k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
28
5.9k
How GitHub Uses GitHub to Build GitHub
holman
467
290k
Building a Modern Day E-commerce SEO Strategy
aleyda
15
6.3k
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