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
38
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
87
Other Decks in Education
See All in Education
2025-10-30 社会と情報2025 #05 CC+の代わり
mapconcierge4agu
0
110
Surviving the surfaceless web
jonoalderson
0
380
卒論の書き方 / Happy Writing
kaityo256
PRO
54
28k
Adobe Express
matleenalaakso
2
8.2k
Going over the Edge
jonoalderson
0
370
Chapitre_2_-_Partie_2.pdf
bernhardsvt
0
170
Flinga
matleenalaakso
3
15k
栃木県警サイバーセキュリティ研修会2026
nomizone
0
200
0121
cbtlibrary
0
130
Postcards
gabrielramirezv
0
120
Use Cases and Course Review - Lecture 8 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
1.4k
IKIGAI World Fes:program
tsutsumi
1
2.6k
Featured
See All Featured
A better future with KSS
kneath
240
18k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
200
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
780
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
0
260
Evolving SEO for Evolving Search Engines
ryanjones
0
130
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
330
[SF Ruby Conf 2025] Rails X
palkan
1
760
The Language of Interfaces
destraynor
162
26k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.7k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.4k
We Have a Design System, Now What?
morganepeng
54
8k
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