Quick intro to regexp internals: think DFA

Source : xkcd
> time perl -e '("a" x 10) =~ /^(a?){10}(a){10}$/;'real 0m0.010s
user 0m0.005s
sys 0m0.004s
> time perl -e '("a" x 25) =~ /^(a?){25}(a){25}$/;'real 0m5.541s
user 0m5.532s
sys 0m0.007s
DFA, recognizing the same langage.
> time perl -e 'print ("a" x 25)' | grep -E "^(a?){25}(a){25}$"
real 0m0.0011s
user 0m0.007s
sys 0m0.007s






Engineering Leader | Author on Decision-Making.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How Did I Copy Windows 10 OS from HDD to Kingston A 1000 M.2 SSD

Keep consistent state across micro-services thanks to Saga pattern

Regular Expressions- Regex with Examples. (In Short)

Why Use React Native for Your Project

From lean-startup via design thinking to implementation

Image result for minimum viable product

Two Flutter projects, two debugging sessions, only one Visual Studio Code instance

Working With gRPC in .Net

Scraping News and Creating a Word Cloud in Python

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adrien Mogenet

Adrien Mogenet

Engineering Leader | Author on Decision-Making.

More from Medium

How Arrays Work?

Sorting:Quick Sort

Data structures: (Doubly) Linked List

Bubble Sort Algorithm