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
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
110
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
AIエージェントと協働するCLI開発 — BunとOpenClawで学んだこと
yoshikouki
1
240
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
13
3.5k
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.6k
oxlintはeslint/typescript-eslintを置き換えられるのか
shomafujita
2
320
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
370
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
17
6.2k
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
120
Spec-Driven Development with AI-Agents: From High-Level Requirements to Working Software
antonarhipov
2
470
Modding RubyKaigi for Myself
yui_knk
0
900
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
600
Swiftのレキシカルスコープ管理
kntkymt
0
220
Technical Debt: Understanding it Rightly, Engaging it Rightly #LaravelLiveJP
shogogg
0
200
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
Amusing Abliteration
ianozsvald
1
200
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
380
Why Our Code Smells
bkeepers
PRO
340
58k
Facilitating Awesome Meetings
lara
57
6.9k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.6k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
380
Discover your Explorer Soul
emna__ayadi
2
1.1k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
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