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
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
93
Lessons learned from building serverless, distributed architecture
dawny33
1
130
Regression Analysis: The good, the bad and untold
dawny33
2
410
Understanding Serverless Architectures
dawny33
2
1.6k
Other Decks in Programming
See All in Programming
Blazing Fast UI Development with Compose Hot Reload (droidcon New York 2025)
zsmb
1
220
明示と暗黙 ー PHPとGoの インターフェイスの違いを知る
shimabox
2
320
ruby.wasmで多人数リアルタイム通信ゲームを作ろう
lnit
2
270
つよそうにふるまい、つよい成果を出すのなら、つよいのかもしれない
irof
1
300
なんとなくわかった気になるブロックテーマ入門/contents.nagoya 2025 6.28
chiilog
1
210
AIエージェントはこう育てる - GitHub Copilot Agentとチームの共進化サイクル
koboriakira
0
380
PHP 8.4の新機能「プロパティフック」から学ぶオブジェクト指向設計とリスコフの置換原則
kentaroutakeda
2
540
Create a website using Spatial Web
akkeylab
0
300
GoのGenericsによるslice操作との付き合い方
syumai
3
690
Google Agent Development Kit でLINE Botを作ってみた
ymd65536
2
190
生成AIで日々のエラー調査を進めたい
yuyaabo
0
650
データの民主化を支える、透明性のあるデータ利活用への挑戦 2025-06-25 Database Engineering Meetup#7
y_ken
0
320
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.5k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
48
2.8k
Fireside Chat
paigeccino
37
3.5k
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.8k
We Have a Design System, Now What?
morganepeng
53
7.7k
Become a Pro
speakerdeck
PRO
28
5.4k
KATA
mclloyd
29
14k
Art, The Web, and Tiny UX
lynnandtonic
299
21k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
The Pragmatic Product Professional
lauravandoore
35
6.7k
Music & Morning Musume
bryan
46
6.6k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
17
940
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