Regex cookbook — Top 15 Most common regex

Jonny Fox
Factory Mind
Published in
4 min readMar 20, 2019

The most commonly used (and most wanted) regexes

UPDATE 10/2022: See further explanations/answers in story responses!

After some time I thought about publishing this article (see my previous tutorial) with the regex I used most in the projects on which I was involved.

Write in the comments any regex that you would like to add and I will try (if I can) to implement them 😅

Happy coding!!!

Alpha-numeric, literals, digits, lowercase, uppercase chars only

\w                //alpha-numeric only
[a-zA-Z] //literals only
//digits only
//lowercase literal only
//uppercase literal only

Simple numbers — try it!

Matches simple numbers only (no decimal nor fractions)

^(\d+)$.          15/12  8.5  12

Decimal numbers — try it!

^(\d*)[.,](\d+)$   15/12  8.5  12  8,7

Fractions — try it!

^(\d+)[\/](\d+)$   15/12  8.5  12

Alphanumeric without spaces — try it!

^(\w*)$            hello123
but not this text

Alphanumeric with spaces — try it!

^(\w*)$            hello123
this text
but not this!

Email (simple — see advanced section for more)

Classic email — try it!

but not this!

Email tokens — try it!


Advanced Regex

Trim spaces — try it!

Matches text avoiding additional spaces


Jonny Fox
Factory Mind