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 01/2024: 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!!!

1. Regex (Base)

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

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

1.2 Simple numbers — try it!

Matches simple numbers only (no decimal nor fractions)

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

1.3 Decimal numbers — try it!

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

1.4 Fractions — try it!

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

--

--

Factory Mind
Factory Mind

Published in Factory Mind

Factory Mind is a young and dynamic cooperative consisting of a team of passionate developers, with a kick for computer science, technology and innovation. The main goal of the cooperative is striving to become a center of excellence and a reference point for software development

Responses (17)