Regex cookbook — Top 10 Most wanted regex
The most commonly used (and most wanted) regexes
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 😅
Trim spaces — try it!
Matches text avoiding additional spaces
HTML Tag — try it!
Matches any valid HTML tag and the corresponding closing tag
Hexadecimal value — try it!
Matches any valid hex color inside text
Valid email (RFC5322) — try it!
Matches any valid email inside text
Username (simple) — try it!
Minimum length of 3, maximum length of 16, composed by letters, numbers or dashes.
Strong password — try it!
Minimum length of 6, at least one uppercase letter, at least one lowercase letter, at least one number, at least one special character
URL (http, https or ftp) — try it!
If you want to use capturing groups to get scheme, path, etc. (or add user-info, host, port…) feel free to ask it in comments!
IPv4 address — try it!
Matches any valid IPv4 address inside text
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
Have fun and do not forget to recommend the article if you liked it 💚
Do not forget to check out my previous article about regex tutorial!