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
210
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
120
Lessons learned from building serverless, distributed architecture
dawny33
1
150
Regression Analysis: The good, the bad and untold
dawny33
2
440
Understanding Serverless Architectures
dawny33
2
1.6k
Other Decks in Programming
See All in Programming
夏だ!祭りだ!祭りとはドメインモデリングでは?
ryugen04
0
280
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
330
20260722_microCMSで考える、AI時代のコンテンツ運用設計
yosh1
0
400
いまどきの Codex で開発する visionOS アプリの開発スタイルについて
karad
0
140
jsmini JavaScript Engine を作ってみた話
yosuke_furukawa
PRO
0
320
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
220
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
2
280
freeeにおけるEvalsの実践例の紹介
freee
PRO
0
110
テーブルをDELETEした
yuzneri
0
140
源内ハンズオン概要編
hideg
0
180
Go 1.27 における memory allocation の高速化
andpad
0
180
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
450
Featured
See All Featured
エンジニアに許された特別な時間の終わり
watany
108
250k
Designing for Performance
lara
611
70k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
280
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
280
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
The Language of Interfaces
destraynor
162
27k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.6k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
430
VelocityConf: Rendering Performance Case Studies
addyosmani
332
25k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
119
120k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
960
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