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
99
Lessons learned from building serverless, distributed architecture
dawny33
1
130
Regression Analysis: The good, the bad and untold
dawny33
2
420
Understanding Serverless Architectures
dawny33
2
1.6k
Other Decks in Programming
See All in Programming
One Enishi After Another
snoozer05
PRO
0
170
Node-REDのノードの開発・活用事例とコミュニティとの関わり(Node-RED Con Nagoya 2025)
404background
0
110
Register is more than clipboard
satorunooshie
1
350
Temporal Knowledge Graphで作る! 時間変化するナレッジを扱うAI Agentの世界
po3rin
5
1.2k
CSC305 Lecture 14
javiergs
PRO
0
210
CSC305 Lecture 11
javiergs
PRO
0
320
Software Architecture
hschwentner
6
2.4k
スキーマ駆動で、Zod OpenAPI Honoによる、API開発するために、Hono Takibiというライブラリを作っている
nakita628
0
330
When Dependencies Fail: Building Antifragile Applications in a Fragile World
selcukusta
0
120
モテるデスク環境
mozumasu
3
1.4k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
490
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
180
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
Java REST API Framework Comparison - PWX 2021
mraible
34
8.9k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Why Our Code Smells
bkeepers
PRO
340
57k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6k
Visualization
eitanlees
150
16k
Building Adaptive Systems
keathley
44
2.8k
The Cost Of JavaScript in 2023
addyosmani
55
9.1k
Building an army of robots
kneath
306
46k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
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