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 with Ruby
Search
Elle Meredith
April 03, 2014
Technology
230
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Regular Expressions with Ruby
What Do You Know? Sydney, 03 April, 2014
Elle Meredith
April 03, 2014
More Decks by Elle Meredith
See All by Elle Meredith
Exploring anti-patterns in Rails
aemeredith
3
490
Strategies for saying no
aemeredith
1
230
Start your own apprenticeship program
aemeredith
0
330
Story-telling with Git rebase
aemeredith
1
1.7k
Algorithms to live by and why should we care
aemeredith
0
820
Feedback matters
aemeredith
0
430
Two heads are better than one
aemeredith
2
1.7k
Feedback Matters
aemeredith
0
450
How I Learn
aemeredith
0
610
Other Decks in Technology
See All in Technology
いま好きなこと 最初はそんなに好きじゃなかった #tamagawadev
nishiuma
1
250
AIエージェントの開発・提供におけるセキュリティリスクの論点と対策
flatt_security
1
510
データエンジニアの困りごとをDevinと一緒に解消する
10xinc
2
750
Nav2、Nav3 ... はたまた自作?〜 作って理解する Nav3 の設計意図 〜 / Nav2, Nav3 ... or Build Your Own? — Understanding Nav3's design intent by building it from scratch
yanzm
0
180
Guerilla InnerSource in enterprises, during the AI hype
onenashev
PRO
0
140
スクラムで身についていた動き方を、XPで捉え直してみた
codmoninc
1
160
Bet AI Day 2026丨バクラク Autopilot、業務システムの再設計
layerx
PRO
2
990
Sony-DroidKaigi2026
sony
1
300
Bet AI Day 2026丨Agentは、「金融」という巨大産業の何を変えられるのか
layerx
PRO
0
640
DGX Sparkを2台使って いろいろ動かす話
sonoda_mj
1
120
Continuous Delivery! It is not what you think it is
tdpauw
0
180
Amazon S3 Tablesに全部任せてみた結果——コンパクション/スナップショット管理は本当に手放せるか
shigeruoda
0
310
Featured
See All Featured
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
590
RailsConf 2023
tenderlove
30
1.5k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
The Invisible Side of Design
smashingmag
301
52k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
800
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.6k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
Mobile First: as difficult as doing things right
swwweet
225
10k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
450
Claude Code のすすめ
schroneko
67
230k
Transcript
Regular Expressions with Ruby Elle Meredith – @aemeredith
Test Extract Change
/fox/ =~ "The quick brown fox" Basic Matching
/fox/ =~ "The quick brown fox" => 16 Basic Matching
/cat/ =~ "The quick brown fox" => nil Basic Matching
/cat/ !~ "The quick brown fox" => true Basic Matching
MatchData string = "The quick brown fox jumps over the
lazy dog”
MatchData string = "The quick brown fox jumps over the
lazy dog” ! matchdata = string.match /fox/ => #<MatchData "fox">
MatchData matchdata.to_s => "fox"
MatchData matchdata.pre_match => "The quick brown "
MatchData matchdata.post_match => " jumps over the lazy dog"
Captures string = "03APR2014" ! string.match /\D{3}/
Captures string = "03APR2014" ! string.match /\D{3}/
Captures string = "03APR2014" ! string.match /\D{3}/
Captures string = "03APR2014" ! string.match /\D{3}/ => #<MatchData "APR">
Captures md = string.match /(.*)(\D{3})(.*)/
Captures md = string.match /(.*)(\D{3})(.*)/
Captures md = string.match /(.*)(\D{3})(.*)/
Captures md = string.match /(.*)(\D{3})(.*)/ => #<MatchData "03APR2014" 1:"03" 2:"APR"
3:"2014">
Captures md.captures => ["03", "APR", "2014"]
Captures md = string.match /(.*)(\D{3})(.*)/ => #<MatchData "03APR2014" 1:"03" 2:"APR"
3:"2014">
Captures md[1] => "03" md[2] => "APR" md[3] => "2014"
Named Captures md = string.match /(?<day>.*)(? <month>\D{3})(?<year>.*)/ => #<MatchData "03APR2014"
day:"03" month:"APR" year:"2014">
Named Captures md = string.match /(?<day>.*)(? <month>\D{3})(?<year>.*)/ => #<MatchData "03APR2014"
day:"03" month:"APR" year:"2014">
Named Captures md = string.match /(?<day>.*)(? <month>\D{3})(?<year>.*)/ => #<MatchData "03APR2014"
day:"03" month:"APR" year:"2014">
Named Captures md = string.match /(?<day>.*)(? <month>\D{3})(?<year>.*)/ => #<MatchData "03APR2014"
day:"03" month:"APR" year:"2014">
Named Captures md['day'] => "03"
Look Around string = ''' I love my job, I
love the pay! I love it more and more each day. I love my boss, he is the best! I love his boss and all the rest. '''
Look Around string.scan /love my/ => ["love my", "love my”]
Positive Lookahead string.scan /love my (?=job)/ => ["love my "]
Changing things string.gsub(/love/, 'hate')
Changing things string.gsub(/love/, 'hate') => "\nI hate my job, I
hate the pay! \nI hate it more and more each day.\nI hate my boss, he is the best!\nI hate his boss and all the rest.\n"
Changing things string.gsub!(/\she/, ' she').gsub!(/ his/, 'her')
Changing things string.gsub!(/\she/, ' she').gsub!(/ his/, 'her')
Changing things string.gsub!(/\she/, ' she').gsub!(/ his/, ‘her') => "\nI love
my job, I love the pay! \nI love it more and more each day. \nI love my boss, she is the best!\nI love her boss and all the rest.\n"
None
Regular Expressions with Ruby Elle Meredith – @aemeredith