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

8 areas where Messenger Chat Extensions will win

What is DNS TTL (Time To Live)?

Explore Power BI Desktop

Debug ASP.NET Core Back-end Created from Web Template Studio

Best practices for improving your website.

Setting up Rails to Send Emails with Amazon SES

Hacking the Netmon, In HackTheBox.

Apache virtual Host on Ubuntu 20.04

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

Sliding Window Algorithm

How to check if a given number is prime or not [python]


Fizzbuzz — An Interview Algorithm Classic