How to Use This Cheat Sheet
Copy any pattern below and test it in our Regex Tester with your own data. Every pattern is battle-tested and includes explanations.
1. Email Validation
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Covers 99% of valid email addresses. For full RFC 5322 compliance you'd need a much longer pattern — but this handles real-world emails perfectly.
2. URL Validation
^https?:\/\/[\w.-]+(?:\.[\w.-]+)+[\w.,@?^=%&:\/~+#-]*$
Matches HTTP and HTTPS URLs with paths, query strings, and fragments.
3. Phone Number (International)
^\+?[1-9]\d{1,14}$
Follows the E.164 international phone number standard. Allows optional + prefix.
4. IPv4 Address
^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$
Validates each octet is 0-255. Rejects values like 999.999.999.999.
5. Date (YYYY-MM-DD)
^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
Validates ISO 8601 date format with proper month (01-12) and day (01-31) ranges.
6. HEX Color
^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$
Matches both shorthand (#FFF) and full (#FFFFFF) hex colors. Use our Color Converter to work with hex colors.
7. Strong Password
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$
Requires: lowercase, uppercase, digit, special character, minimum 8 characters. Test password strength with our Password Entropy Calculator.
8. URL Slug
^[a-z0-9]+(?:-[a-z0-9]+)*$
Validates clean URL slugs (lowercase letters, numbers, hyphens). Generate slugs with our URL Slug Generator.
9. HTML Tags
<\/?[a-z][\s\S]*?>
Matches opening, closing, and self-closing HTML tags. Useful for stripping HTML from text.
10. Excessive Whitespace
\s{2,}
Matches 2+ consecutive whitespace characters. Replace with a single space to clean text. Or use our Remove Extra Spaces tool.
11. Credit Card Number (Basic)
^\d{4}[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}$
Matches 16-digit card numbers with optional spaces or dashes. For masking, use our Credit Card Mask tool.
12. UUID v4
^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
Validates UUID version 4 format specifically (note the 4 in the third group).
13. JSON Key Extraction
"([^"]+)"\s*:
Extracts all keys from a JSON string. Useful for quick analysis. For proper JSON work, use our JSON Formatter.
14. Markdown Links
\[([^\]]+)\]\(([^)]+)\)
Captures both the link text (group 1) and URL (group 2) from Markdown links.
15. Trailing Slash Removal
\/$
Matches a trailing slash at the end of a URL. Replace with empty string to normalize URLs for SEO.
Test Any Pattern
Copy any pattern above and paste it into our Regex Tester. It shows live matching, capture groups, and match highlighting — all running locally in your browser.