DEV Community

Cover image for 20 Small Steps to Become a Regex Master

20 Small Steps to Become a Regex Master

Andrew (he/him) on November 09, 2019

"For the love of money is the root of all evil..." -- King James Bible, 1 Timothy 6:10 Cover image by msandersmusic from Pixabay The above ...
Collapse
 
gypsydave5 profile image
David Wickes

The best way to get better at regexes is to use them - practice, practice, practice! So what's the best way to give yourself the opportunity to practice?

Here are some ideas:

  • Use a text editor that supports making changes using regexes, for instance vim or ed. By forcing yourself to use regexes for all text changes you get the basics down pretty quickly.

  • Use tools like sed and grep on the command line at every opportunity. Both are driven by regexes.

The cost of this approach is that you will suffer an initial hit on productivity. But it will pay off on the end.

Collapse
 
awwsmm profile image
Andrew (he/him)

sed and grep are fantastic tools! 100% recommended!

Collapse
 
logeekal profile image
Jatin Kathuria

It is a great one stop shop for regex....thank you for making the effort.

Collapse
 
awwsmm profile image
Andrew (he/him)

Thank you for reading!

Collapse
 
prashant profile image
Prashant Nigam

Very nicely written Andrew. Goes straight to my reading list for future reference

Collapse
 
awwsmm profile image
Andrew (he/him)

Happy to hear that, Prashant! Thanks for reading!

Collapse
 
marcellothearcane profile image
marcellothearcane
Collapse
 
awwsmm profile image
Andrew (he/him)

A classic

Collapse
 
tyrrrz profile image
Oleksii Holub

Regex-schmegex, is that a screenshot from Dusk?

Collapse
 
tyrrrz profile image
Oleksii Holub

No it's not, I remember it prettier than it actually is.

steamcommunity.com/sharedfiles/fil...

Collapse
 
awwsmm profile image
Andrew (he/him)

Yeah the photo is of the chapel at Thanks-Giving Square in downtown Dallas, TX.

Collapse
 
farahanjum profile image
Farah Anjum

Great article. I'd have liked the answers to be visible in the post itself, rather than as outbound links. Suggestion for next time maybe :D

Collapse
 
monishvm profile image
M O N I S H

what about this for step 18 last problem

/(?! )([1-9][0-9]{0,}.[0-9]{1,})(?!%)/gm

Collapse
 
amoawad89 profile image
amoawad89

is there a good website to practice the RegEx from neutral point of view not programming language as I am not a programmer but sometimes I need RegEx to look into log files and filter them

Collapse
 
halilcanozcelik profile image
Halil Can Ozcelik • Edited

Firstly, thanks for this nice article. However, in step 6 pop quiz, the answer for years between 1977-1982 is wrong. Because it also matches with 1987, etc.