RegexCheatsheetProductivity
5 Common Regex Patterns Every Developer Should Know
DevToolVault Team•
Why reinvent the wheel? Here are 5 patterns you'll use again and again.
1. Email Address
^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$
2. Phone Number (US)
^(\([0-9]{3}\) |[0-9]{3}-)[0-9]{3}-[0-9]{4}$
3. Date (YYYY-MM-DD)
^\d{4}-\d{2}-\d{2}$
4. URL
https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)
5. Hex Color
^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$
Test these out in our Regex Tester!
Try the Tool
Ready to put this into practice? Check out our free Regex tool.