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
200
1
Share
The 1960s elegance behind Go's regexp
The presentation is given at FOSS Asia Summit 2017
Jalem Raj Rohit
March 19, 2017
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
TiDBのアーキテクチャから学ぶ分散システム入門 〜MySQL互換のNewSQLは何を解決するのか〜 / tidb-architecture-study
dznbk
1
190
Programming with a DJ Controller — not vibe coding
m_seki
3
240
AIエージェントで業務改善してみた
taku271
0
540
How We Benchmarked Quarkus: Patterns and anti-patterns
hollycummins
1
160
10 Tips of AWS ~Gen AI on AWS~
licux
5
470
AIベース静的検査器の偽陽性率を抑える工夫3選
orgachem
PRO
4
360
アクセシビリティ試験の"その後"を仕組み化する
yuuumiravy
1
180
ハーネスエンジニアリングとは?
kinopeee
13
6.2k
属人化しないコード品質の作り方_2026.04.07.pdf
muraaano
0
240
Spec Driven Development | AI Summit Vilnius
danielsogl
PRO
1
110
GitHubCopilotCLIをはじめよう.pdf
htkym
0
270
YJITとZJITにはイカなる違いがあるのか?
nakiym
0
250
Featured
See All Featured
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
100
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.7k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
820
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
New Earth Scene 8
popppiees
3
2.1k
A better future with KSS
kneath
240
18k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
780
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.4k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
330
Leo the Paperboy
mayatellez
7
1.7k
The Cult of Friendly URLs
andyhume
79
6.8k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1k
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