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
1
180
The 1960s elegance behind Go's regexp
The presentation is given at FOSS Asia Summit 2017
Jalem Raj Rohit
March 19, 2017
Tweet
Share
More Decks by Jalem Raj Rohit
See All by Jalem Raj Rohit
Training and leveraging graph embeddings at scale
dawny33
2
86
Lessons learned from building serverless, distributed architecture
dawny33
1
120
Regression Analysis: The good, the bad and untold
dawny33
2
400
Understanding Serverless Architectures
dawny33
2
1.5k
Other Decks in Programming
See All in Programming
⚪⚪の⚪⚪をSwiftUIで再現す る
u503
0
160
はじめての Go * WASM * OCR
sgash708
1
150
フロントエンドオブザーバビリティ on Google Cloud
yunosukey
0
140
やっと腹落ち「スプリント毎に動くモノをリリースする」〜ゼロから始めるメガバンクグループのアジャイル実践〜
sasakendayo
0
300
Expoによるアプリ開発の現在地とReact Server Componentsが切り開く未来
yukukotani
2
350
Scala 3 で GLSL のための c-like-for を実装してみた
exoego
1
140
AWS Step Functions は CDK で書こう!
konokenj
5
980
iOSでQRコード生成奮闘記
ktcryomm
2
180
AIレビュー導入によるCIツールとの共存と最適化
kamo26sima
1
1.4k
読まないコードリーディング術
hisaju
1
180
SwiftUI移行のためのインプレッショントラッキング基盤の構築
kokihirokawa
0
230
バックエンドNode.js × フロントエンドDeno で開発して得られた知見
ayame113
4
1.1k
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
34
2.6k
Mobile First: as difficult as doing things right
swwweet
223
9.5k
Music & Morning Musume
bryan
46
6.4k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.5k
Large-scale JavaScript Application Architecture
addyosmani
511
110k
The Cost Of JavaScript in 2023
addyosmani
48
7.5k
For a Future-Friendly Web
brad_frost
176
9.6k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
GraphQLとの向き合い方2022年版
quramy
44
14k
Become a Pro
speakerdeck
PRO
26
5.2k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
1.1k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.3k
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