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
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
32
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
78
Other Decks in Education
See All in Education
Virtual and Augmented Reality - Lecture 8 - Next Generation User Interfaces (4018166FNR)
signer
PRO
0
1.7k
2025年度春学期 統計学 第3回 クロス集計と感度・特異度,データの可視化 (2025. 4. 24)
akiraasano
PRO
0
130
モンテカルロ法(3) 発展的アルゴリズム / Simulation 04
kaityo256
PRO
7
1.3k
子どものためのプログラミング道場『CoderDojo』〜法人提携例〜 / Partnership with CoderDojo Japan
coderdojojapan
4
16k
SkimaTalk Tutorial for Students
skimatalk
0
1.8k
Dashboards - Lecture 11 - Information Visualisation (4019538FNR)
signer
PRO
1
2.1k
第1回大学院理工学系説明会|東京科学大学(Science Tokyo)
sciencetokyo
PRO
0
3.9k
Tangible, Embedded and Embodied Interaction - Lecture 7 - Next Generation User Interfaces (4018166FNR)
signer
PRO
0
1.7k
技術勉強会 〜 OAuth & OIDC 入門編 / 20250528 OAuth and OIDC
oidfj
5
1.3k
プレゼンテーション実践
takenawa
0
6.5k
登壇未経験者のための登壇戦略~LTは設計が9割!!!~
masakiokuda
3
550
人になにかを教えるときに考えていること(2025-05版 / VRC-LT #18)
sksat
4
1k
Featured
See All Featured
A Tale of Four Properties
chriscoyier
160
23k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Fireside Chat
paigeccino
37
3.5k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
Writing Fast Ruby
sferik
628
62k
The Pragmatic Product Professional
lauravandoore
35
6.7k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.7k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.6k
Raft: Consensus for Rubyists
vanstee
140
7k
Art, The Web, and Tiny UX
lynnandtonic
299
21k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Making Projects Easy
brettharned
116
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