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
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
AzureでのIaC - Bicep? Terraform? それ早く言ってよ会議
torumakabe
1
580
SREが向き合う大規模リアーキテクチャ 〜信頼性とアジリティの両立〜
zepprix
0
460
SREチームをどう作り、どう育てるか ― Findy横断SREのマネジメント
rvirus0817
0
310
こんなところでも(地味に)活躍するImage Modeさんを知ってるかい?- Image Mode for OpenShift -
tsukaman
1
160
仕様書駆動AI開発の実践: Issue→Skill→PRテンプレで 再現性を作る
knishioka
2
680
AIエージェントに必要なのはデータではなく文脈だった/ai-agent-context-graph-mybest
jonnojun
0
100
Context Engineeringが企業で不可欠になる理由
hirosatogamo
PRO
3
620
ランサムウェア対策としてのpnpm導入のススメ
ishikawa_satoru
0
180
プロダクト成長を支える開発基盤とスケールに伴う課題
yuu26
4
1.3k
OWASP Top 10:2025 リリースと 少しの日本語化にまつわる裏話
okdt
PRO
3
820
Cosmos World Foundation Model Platform for Physical AI
takmin
0
940
学生・新卒・ジュニアから目指すSRE
hiroyaonoe
2
650
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
515
110k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
180
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
150
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.9k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
130
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
290
How to Talk to Developers About Accessibility
jct
2
130
Designing for humans not robots
tammielis
254
26k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.1k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
230
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
140
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]