Common Regular Expressions
Here is a collection of high-frequency regular expressions for frontend and backend development. You can copy and test them in real-time using our Online Regex Tool.
1. Email Address
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Basic email format validation, matching most common email addresses.
2. Phone Number (US/General)
^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$
Matches US format like (123) 456-7890 or 123-456-7890.
3. URL (HTTP/HTTPS)
https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)
4. Date (YYYY-MM-DD)
^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$
5. Strong Password
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$
Requires at least 8 chars, one uppercase, one lowercase, one number, and one special character.
6. Hex Color
^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$