Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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
37
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
85
Other Decks in Education
See All in Education
コマンドラインを見直そう(1995年からタイムリープ)
sapi_kawahara
0
590
ロータリー国際大会について~国際大会に参加しよう~:古賀 真由美 会員(2720 Japan O.K. ロータリーEクラブ・(有)誠邦産業 取締役)
2720japanoke
1
740
【ZEPメタバース校舎操作ガイド】
ainischool
0
690
The Next Big Step Toward Nuclear Disarmament
hide2kano
0
160
AIは若者の成長機会を奪うのか?
frievea
0
130
20251119 如果是勇者欣美爾的話, 他會怎麼做? 東海資工
pichuang
0
140
HyRead2526
cbtlibrary
0
160
the difficulty into words
ukky86
0
320
あなたの言葉に力を与える、演繹的なアプローチ
logica0419
1
240
1014
cbtlibrary
0
500
【ZEPホスト用メタバース校舎操作ガイド】
ainischool
0
150
ThingLink
matleenalaakso
28
4.2k
Featured
See All Featured
The World Runs on Bad Software
bkeepers
PRO
72
12k
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.3k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.3k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Code Review Best Practice
trishagee
74
19k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
34k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.5k
Making the Leap to Tech Lead
cromwellryan
135
9.7k
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