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
Jalem Raj Rohit
March 19, 2017
Programming
1
160
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
83
Lessons learned from building serverless, distributed architecture
dawny33
1
120
Regression Analysis: The good, the bad and untold
dawny33
2
390
Understanding Serverless Architectures
dawny33
2
1.5k
Other Decks in Programming
See All in Programming
のびしろを広げる巻き込まれ力:偶然を活かすキャリアの作り方/oso2024
takahashiikki
1
250
offers_20241022_imakiire.pdf
imakurusu
1
130
/←このスケジュール表に立ち向かう フロントエンド開発戦略 / A front-end development strategy to tackle a single-slash schedule.
nrslib
1
430
Vue3の一歩踏み込んだパフォーマンスチューニング2024
hal_spidernight
3
2k
20241004 モノタロウ式~ドメインモデリングとリアーキテクチャ
monotaro
PRO
2
680
Serverless renderování Webových komponent
rarous
PRO
0
140
GrafanaのHTTP API を眺めてみよう
rinchoku
0
470
CSC509 Lecture 04
javiergs
PRO
0
170
CSC305 Lecture 09
javiergs
PRO
0
120
モジュラモノリス、その前に / Modular monolith, before that
euglena1215
8
750
【YAPC::Hakodate 2024】TypeScriptエンジニアが感じたPerlのここが面白い
kimitashoichi
1
480
App Store Connect APIで 作業時間を増やそう
mot_techtalk
3
140
Featured
See All Featured
Building Applications with DynamoDB
mza
90
6k
The Power of CSS Pseudo Elements
geoffreycrofte
71
5.3k
Ruby is Unlike a Banana
tanoku
96
11k
A Tale of Four Properties
chriscoyier
156
22k
Imperfection Machines: The Place of Print at Facebook
scottboms
264
13k
For a Future-Friendly Web
brad_frost
174
9.4k
It's Worth the Effort
3n
183
27k
Automating Front-end Workflow
addyosmani
1365
200k
Producing Creativity
orderedlist
PRO
341
39k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
Embracing the Ebb and Flow
colly
84
4.4k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
355
29k
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