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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
440
Understanding Serverless Architectures
dawny33
2
1.6k
Other Decks in Programming
See All in Programming
決定論 vs 確率論:Gemini 3 FlashとTF-IDFを組み合わせた「法規判定エンジン」の構築
shukob
0
170
プロパティの順序で型推論が壊れる!? TypeScript6.0の修正からContext-Sensitivityの仕組みを追う
bicstone
2
590
リセットCSSを1行消したらアクセシビリティが向上した話
pvcresin
4
520
My daily life on Ruby
a_matsuda
3
420
AI Agent と正しく分析するための環境作り
yoshyum
2
560
Structured Concurrency, Scoped Values and Joiners in the JDK 25 26 27
josepaumard
1
160
Modding RubyKaigi for Myself
yui_knk
0
370
関係性から理解する"同一性"の型用語たち
pvcresin
2
280
【ディップ|26年新卒研修資料】TDD実装演習
dip_tech
PRO
0
290
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
460
ビジネスモデルから紐解く、AI+型駆動開発
hirokiomote
2
660
AIチームを指揮するOSS「TAKT」活用術 / How to Use “TAKT,” an OSS Tool for Orchestrating AI Teams
nrslib
1
330
Featured
See All Featured
Bash Introduction
62gerente
615
210k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
120
Chasing Engaging Ingredients in Design
codingconduct
0
190
Six Lessons from altMBA
skipperchong
29
4.2k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
250
ラッコキーワード サービス紹介資料
rakko
1
3.3M
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.6k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
280
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.9k
Producing Creativity
orderedlist
PRO
348
40k
Speed Design
sergeychernyshev
33
1.7k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
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