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
1
190
The 1960s elegance behind Go's regexp
The presentation is given at FOSS Asia Summit 2017
Jalem Raj Rohit
March 19, 2017
Tweet
Share
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
Swift ConcurrencyでよりSwiftyに
yuukiw00w
0
250
AI活用のコスパを最大化する方法
ochtum
0
120
AIとペアプロして処理時間を97%削減した話 #pyconshizu
kashewnuts
1
210
Geminiの機能を調べ尽くしてみた
naruyoshimi
0
200
15年目のiOSアプリを1から作り直す技術
teakun
1
610
Python’s True Superpower
hynek
0
200
ふつうのRubyist、ちいさなデバイス、大きな一年 / Ordinary Rubyists, Tiny Devices, Big Year
chobishiba
1
390
Takumiから考えるSecurity_Maturity_Model.pdf
gessy0129
1
120
手戻りゼロ? Spec Driven Developmentとは@KAG AI week
tmhirai
1
170
CSC307 Lecture 11
javiergs
PRO
0
590
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
400
Windows on Ryzen and I
seosoft
0
190
Featured
See All Featured
The untapped power of vector embeddings
frankvandijk
2
1.6k
Facilitating Awesome Meetings
lara
57
6.8k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
81
SEO for Brand Visibility & Recognition
aleyda
0
4.3k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
260
Evolving SEO for Evolving Search Engines
ryanjones
0
150
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
310
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.3k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
240
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