Regex Tester

Test and validate regular expressions with real-time matching

Common Patterns

Email Address
Matches valid email addresses
/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/i
URL
Matches URLs with optional protocol
/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/i
Phone Number (US)
Matches US phone numbers with optional country code
/^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/
Date (YYYY-MM-DD)
Matches dates in YYYY-MM-DD format
/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/
Time (24h)
Matches 24-hour time format (HH:MM)
/^([01]\d|2[0-3]):([0-5]\d)$/
Password Strength
Minimum 8 characters, at least one letter, one number, and one special character
/^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$/
IPv4 Address
Matches valid IPv4 addresses
/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
Credit Card Number
Matches major credit card numbers (Visa, MasterCard, Amex, Discover)
/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|6(?:011|5[0-9][0-9])[0-9]{12})$/
Hex Color
Matches hex color codes with optional #
/^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/
ZIP Code (US)
Matches US ZIP codes with optional +4
/^\d{5}(?:[-\s]\d{4})?$/