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
The 1960s elegance behind Go's regexp
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Jalem Raj Rohit
March 19, 2017
Programming
190
1
Share
The 1960s elegance behind Go's regexp
The presentation is given at FOSS Asia Summit 2017
Jalem Raj Rohit
March 19, 2017
More Decks by Jalem Raj Rohit
See All by Jalem Raj Rohit
Training and leveraging graph embeddings at scale
dawny33
2
110
Lessons learned from building serverless, distributed architecture
dawny33
1
140
Regression Analysis: The good, the bad and untold
dawny33
2
430
Understanding Serverless Architectures
dawny33
2
1.6k
Other Decks in Programming
See All in Programming
仕様漏れ実装漏れをなくすトレーサビリティAI基盤のご紹介
orgachem
PRO
8
4k
Mastering Event Sourcing: Your Parents Holidayed in Yugoslavia
super_marek
0
130
20260320登壇資料
pharct
0
140
それはエンジニアリングの糧である:AI開発のためにAIのOSSを開発する現場より / It serves as fuel for engineering: insights from the field of developing open-source AI for AI development.
nrslib
1
820
テレメトリーシグナルが導くパフォーマンス最適化 / Performance Optimization Driven by Telemetry Signals
seike460
PRO
2
200
PHP でエミュレータを自作して Ubuntu を動かそう
m3m0r7
PRO
2
160
Kubernetesでセルフホストが簡単なNewSQLを求めて / Seeking a NewSQL Database That's Simple to Self-Host on Kubernetes
nnaka2992
0
190
存在論的プログラミング: 時間と存在を記述する
koriym
5
740
Geminiをパートナーに神社DXシステムを個人開発した話(いなめぐDX 開発振り返り)
fujiba
0
130
KagglerがMixSeekを触ってみた
morim
0
360
Tamach-sre-3_ANDPAD-shimaison93
mane12yurks38
0
240
メッセージングを利用して時間的結合を分離しよう #phperkaigi
kajitack
3
540
Featured
See All Featured
The Spectacular Lies of Maps
axbom
PRO
1
670
Tell your own story through comics
letsgokoyo
1
880
Typedesign – Prime Four
hannesfritz
42
3k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.2k
Facilitating Awesome Meetings
lara
57
6.8k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
Context Engineering - Making Every Token Count
addyosmani
9
790
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.5k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Mind Mapping
helmedeiros
PRO
1
140
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.5k
Amusing Abliteration
ianozsvald
1
150
Transcript
The 1960s elegance behind Go’s regexp 19 MarchFOSS Asia ‘17
Jalem Raj Rohit
What this talk is about? About the two approaches to
regex matching. - One used in almost all standard regex interpreters, like Python, Perl, etc - The other one used in some implementations like, awk, grep, sed, etc And Go, of course
What exactly are Regular Expressions? - It’s a style of
describing character strings - If a string successfully describes a regex, then it is called a match
Examples: Let’s say e1 matches “s” and e2 matches “t”:
➔ Alternation If e1 | e2 ⇒ s or it ➔ Concatenation e1 e2 ⇒ st. ➔ e1* 0 or more s ➔ e1+ 1 or more s
Perl vs Golang time comparison for matching a?a?a?aaa with respect
to the string length
Aaaand welcome to: The world of super awesome Computer Science
! and Super awesome algorithms !
Meet Finite Automata - It’s also known as State Machines
- ← This one is a Deterministic Finite Automata (or a DFA)
Also, meet NFA - NFA stands for Nondeterministic Finite Automata
- Example on the left - It has multiple legit choices in state S2 Which one to choose? :( - Also, the machine can’t peek ahead
Converting Regexes to NFAs - This would be the basic
unit of the NFA - Concatenation be like: - Aaaand alternation
Perl’s algorithm at work - Also, called the backtracking approach
- Time complexity grows exponentially for pathological regex matches, as the string size grows. - Literally, out of the window
Can we make this better?
Thompson’s algorithm at work - Guesses both options simultaneously -
Allows the machine to be in multiple states at the same time - Linear time complexity. Yayyy !!!
Again, comparison of the algorithms
Again ….
Special Shoutout to GopherData - An attempt to bring together
Go’s and gophers’ efforts in Data Science and Analytics - Github: https://github.com/gopherdata - Twitter: https://twitter.com/GopherDataIO
THANK YOU - Github: Dawny33 - Twitter: @data__wizard (<-- 2
_’s there) - Facebook: rajrohit.33