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
Regular Expressions Basics Lesson for Ada Academy
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
nellshamrell
September 26, 2014
Technology
0
46
Regular Expressions Basics Lesson for Ada Academy
nellshamrell
September 26, 2014
Tweet
Share
Other Decks in Technology
See All in Technology
制約が導く迷わない設計 〜 信頼性と運用性を両立するマイナンバー管理システムの実践 〜
bwkw
3
970
コスト削減から「セキュリティと利便性」を担うプラットフォームへ
sansantech
PRO
3
1.5k
コミュニティが変えるキャリアの地平線:コロナ禍新卒入社のエンジニアがAWSコミュニティで見つけた成長の羅針盤
kentosuzuki
0
120
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
10k
What happened to RubyGems and what can we learn?
mikemcquaid
0
310
こんなところでも(地味に)活躍するImage Modeさんを知ってるかい?- Image Mode for OpenShift -
tsukaman
1
160
Cosmos World Foundation Model Platform for Physical AI
takmin
0
940
AWS Network Firewall Proxyを触ってみた
nagisa53
1
240
SRE Enabling戦記 - 急成長する組織にSREを浸透させる戦いの歴史
markie1009
0
130
SREじゃなかった僕らがenablingを通じて「SRE実践者」になるまでのリアル / SRE Kaigi 2026
aeonpeople
6
2.5k
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
6
68k
[CV勉強会@関東 World Model 読み会] Orbis: Overcoming Challenges of Long-Horizon Prediction in Driving World Models (Mousakhan+, NeurIPS 2025)
abemii
0
140
Featured
See All Featured
It's Worth the Effort
3n
188
29k
Designing for humans not robots
tammielis
254
26k
Scaling GitHub
holman
464
140k
Side Projects
sachag
455
43k
Exploring anti-patterns in Rails
aemeredith
2
250
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
330
Building Flexible Design Systems
yeseniaperezcruz
330
40k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.6k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
110
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.3k
Un-Boring Meetings
codingconduct
0
200
Transcript
REGULAR EXPRESSIONS Nell Shamrell @nellshamrell
What is a regular expression? It’s a pattern.
How do you make a regular expression? /RegularExpression/
What can you do with a regular expression?
Test Extract Change
Test Extract Change
Test Extract Change
Testing a String
“Use the force”
/force/ “Use the force”
=~
/force/ =~ “Use the force”
“Use the force” =~ /force/
/force/ =~ “Use the force” => 8
/dark side/ !~ “Use the force”
/dark side/ !~ “Use the force” => true
MatchData
match
string = “The force will be with you always.”
string = “The force will be with you always.” m
= /force/.match(string)
string = “The force will be with you always.” m
= /force/.match(string) => #<MatchData “force” >
What can you do with MatchData?
m = /force/.match(string)
m = /force/.match(string) m.to_s
m = /force/.match(string) m.to_s => “force”
m = /force/.match(string)
m = /force/.match(string) m.pre_match
m = /force/.match(string) m.pre_match => “The ”
m = /force/.match(string)
m = /force/.match(string) m.post_match
m = /force/.match(string) m.post_match => “ will be with you
always ”
Email Validation
[email protected]
Rubular
Alternation /nell | renee /
. * any single character character can appear any number
of times
/.*/ Matches ANYTHING
Range [a-d] [1-4]
\w stands for any word character same as [a-zA-Z0-9_]
+ character must appear one or more times
None
Extracting Strings
\d stands for any digit same as [0-9]
\d{3} looks for exactly 3 digits
? makes a character optional
Changing a String
string = “Renee is presenting to the class right now.
Renee is presenting on regular expressions.”
sub(/regex/, “text”)
string = “Renee is presenting to the class right now.
Renee is presenting on regular expressions.”
string = “Renee is presenting to the class right now.
Renee is presenting on regular expressions.” new = string.sub(/Renee/, “Nell”)
new = string.sub(/Renee/, “Nell”) => “Nell is presenting to the
class right now. Renee is presenting on regular expressions.”
gsub(/regex/, “text”)
new = string.gsub(/Renee/, “Nell”)
=> “Nell is presenting to the class right now. Nell
is presenting on regular expressions.” new = string.gsub(/Renee/, “Nell”)
string.gsub!(/Renee/, “Nell”)
Welcome to the world of regular expressions!
https://gist.github.com/ nellshamrell/6938008 Resources
Contact Info Nell Shamrell @nellshamrell
[email protected]