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.7k
Other Decks in Programming
See All in Programming
MySQLとPostgreSQLって何が違うの?
akagami
0
160
ソフトウェアラスタライザ
fadis
1
760
Flow は今どうなっているか
mizdra
PRO
0
830
AWS Transform Customによる Spring Boot 2.xから4.xへのVerUp
satoshi256kbyte
2
120
夏だ!祭りだ!祭りとはドメインモデリングでは?
ryugen04
0
510
KotlinConf Extended South Korea 2026 Keynote
l2hyunwoo
0
130
typoなんかねぇよ
raspython3
0
640
kubernetes コンポーネント開発入門 / 新卒N年目の勉強会&交流会!〜〇〇への誘い〜 #n_study
mazrean
0
130
AIと壁打ちしながら進めるコスト管理
fufuhu
2
1.9k
ALB ログから Trace を気合で繋げる技術
fohte
7
840
Claude Codeを組織的に動かして月400PRを実現した話
happy_ryo
0
240
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
210
Featured
See All Featured
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
660
Bash Introduction
62gerente
615
220k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
500
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
430
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
390
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
460
Six Lessons from altMBA
skipperchong
29
4.5k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
320
Chasing Engaging Ingredients in Design
codingconduct
0
290
Joys of Absence: A Defence of Solitary Play
codingconduct
1
460
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
490
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