ToolsJanuary 29, 2026
Regex Tester: 20 Common Patterns with Examples
Master regular expressions with our interactive tester. Learn 20 common patterns for email, URL, phone validation, and more.
regexregular expressionsvalidationtext processing
Regular expressions (regex) are powerful patterns for matching and manipulating text. They're essential for validation, search and replace, and text processing. This guide provides 20 common regex patterns you can use immediately, plus our interactive tester to build and debug your own patterns.
20 Common Regex Patterns
// Email validation
/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
// URL validation
/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b/
// Phone number (US)
/^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/
// Date (YYYY-MM-DD)
/^\d{4}-\d{2}-\d{2}$/
// ZIP code (US)
/^\d{5}(-\d{4})?$/
// Credit card number
/^\d{4}[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}$/
// Strong password (8+ chars, uppercase, lowercase, number, special)
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/
// Hex color code
/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/
// IPv4 address
/^((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]?)$/
// Username (alphanumeric, underscore, 3-16 chars)
/^[a-zA-Z0-9_]{3,16}$/🔍 Try our free Regex Tester
Try it freeHow to Use the Regex Tester
- •Step 1: Enter your regex pattern
- •Step 2: Add test strings to match against
- •Step 3: See which strings match and why
- •Step 4: Adjust and iterate until perfect
Regex Best Practices
- •Start simple — Build complex patterns incrementally
- •Test edge cases — Empty strings, special characters, long inputs
- •Use non-capturing groups — (?:...) when you don't need the match
- •Escape special characters — \. \? \+ \* etc.
- •Comment complex regex — Use verbose mode in some languages