Regex Basics Refresher
Before diving into patterns, let's review the essential regex syntax:
| Character | Meaning | Example |
|---|---|---|
. | Any character | a.c matches "abc", "a1c" |
* | Zero or more | ab* matches "a", "ab", "abbb" |
+ | One or more | ab+ matches "ab", "abbb" |
? | Zero or one | colou?r matches "color", "colour" |
^ | Start of string | ^hello |
$ | End of string | world$ |
\d | Digit (0-9) | \d{3} matches "123" |
\w | Word character | \w+ matches "hello" |
\s | Whitespace | \s+ matches spaces |
[abc] | Character class | [aeiou] matches vowels |
(a|b) | Alternation | (cat|dog) |
{n,m} | Quantifier | \d{2,4} matches 2-4 digits |
Email Validation Patterns
1. Basic Email
Simple email validation for most use cases
2. Simple Email (Quick Check)
Minimal validation - just checks for @ and domain
URL & Web Patterns
3. URL with HTTP/HTTPS
Validates web URLs with optional www
4. URL Slug
SEO-friendly URL slugs
5. Domain Name
Validates domain names without protocol
6. IPv4 Address
Validates IP addresses (0-255 per octet)
Phone Number Patterns
7. US Phone Number
Matches (123) 456-7890, 123-456-7890, 123.456.7890
8. International Phone (E.164)
International format with country code
Test Your Regex Patterns
Use our free regex tester to validate patterns and see matches in real-time.
Open Regex Tester →Date & Time Patterns
9. ISO 8601 Date (YYYY-MM-DD)
International standard date format
10. US Date (MM/DD/YYYY)
US date format with validation
11. 24-Hour Time
HH:MM format (00:00 to 23:59)
12. ISO 8601 DateTime
Full datetime with timezone
Password Validation
13. Strong Password
Min 8 chars, uppercase, lowercase, number, special char
14. Medium Password
Min 8 chars, uppercase, lowercase, number
Numbers & Currency
15. Integer
Positive or negative whole numbers
16. Decimal Number
Numbers with optional decimal places
17. USD Currency
US dollar amounts with optional commas
18. Percentage
Percentage values with decimals
IDs & Codes
19. UUID v4
Standard UUID format
20. Credit Card Number
Visa, MasterCard, Amex, Discover
21. US ZIP Code
5-digit or ZIP+4 format
22. Hex Color Code
3 or 6 digit hex colors
23. MAC Address
Network MAC address
Text Processing Patterns
24. Extract Hashtags
Find Twitter/social media hashtags
25. Extract @Mentions
Find user mentions
26. Remove Multiple Spaces
Find 2+ consecutive spaces
27. HTML Tags
Match HTML tags (for stripping)
Code & Development Patterns
28. Semantic Version
SemVer format (major.minor.patch)
29. Git Commit Hash
Short or full commit SHA
30. JWT Token
JSON Web Token format
Pro Tip: Always test regex patterns with edge cases. A pattern that works for common inputs may fail on unusual but valid data.
Multi-Language Examples
JavaScript
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
// Test
emailRegex.test('user@example.com'); // true
// Extract matches
const text = 'Contact us at info@example.com or support@example.com';
const emails = text.match(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g);
// ['info@example.com', 'support@example.com']
Python
import re
email_pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
# Test
if re.match(email_pattern, 'user@example.com'):
print('Valid email')
# Find all
text = 'Contact info@example.com or support@example.com'
emails = re.findall(r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}', text)
# ['info@example.com', 'support@example.com']
PHP
$pattern = '/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/';
// Test
if (preg_match($pattern, 'user@example.com')) {
echo 'Valid email';
}
// Find all
$text = 'Contact info@example.com or support@example.com';
preg_match_all('/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/', $text, $matches);
// $matches[0] = ['info@example.com', 'support@example.com']
Explore More Regex Patterns
Browse our library of 100+ ready-to-use regex patterns with detailed explanations.
View Regex Library →