Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
100
Lessons learned from building serverless, distributed architecture
dawny33
1
140
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
Google Antigravity and Vibe Coding: Agentic Development Guide
mickey_kubo
2
130
全員アーキテクトで挑む、 巨大で高密度なドメインの紐解き方
agatan
8
18k
GeistFabrik and AI-augmented software development
adewale
PRO
0
250
251126 TestState APIってなんだっけ?Step Functionsテストどう変わる?
east_takumi
0
300
テストやOSS開発に役立つSetup PHP Action
matsuo_atsushi
0
140
Full-Cycle Reactivity in Angular: SignalStore mit Signal Forms und Resources
manfredsteyer
PRO
0
180
Microservices rules: What good looks like
cer
PRO
0
570
関数の挙動書き換える
takatofukui
4
770
CSC509 Lecture 14
javiergs
PRO
0
220
AIエンジニアリングのご紹介 / Introduction to AI Engineering
rkaga
3
1.1k
社内オペレーション改善のためのTypeScript / TSKaigi Hokuriku 2025
dachi023
1
490
AIコーディングエージェント(NotebookLM)
kondai24
0
130
Featured
See All Featured
Code Review Best Practice
trishagee
73
19k
Documentation Writing (for coders)
carmenintech
76
5.2k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.1k
Visualization
eitanlees
150
16k
Mobile First: as difficult as doing things right
swwweet
225
10k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
KATA
mclloyd
PRO
32
15k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
For a Future-Friendly Web
brad_frost
180
10k
Bash Introduction
62gerente
615
210k
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