Common Regex Patterns: Email, URL, Phone and More (Copy-Paste)
Ready-to-use regular expressions for the things developers validate and extract most often. Copy a pattern and drop it in. New to regex? Read our beginner's guide and keep the regex cheat sheet open to understand how each one works.
Updated 2026-07-06
| Matches | Pattern | Notes |
|---|---|---|
| Email (pragmatic) | ^[\w.+-]+@[\w-]+\.[\w.-]+$ | Good enough for forms; no regex is fully RFC-correct |
| URL (http/https) | https?://[^\s]+ | Matches a URL starting with http:// or https:// |
| IPv4 address | \b(?:\d{1,3}\.){3}\d{1,3}\b | Doesn't check that each part is 0–255 |
| Hex color | ^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$ | 3- or 6-digit hex, with leading # |
| Date (YYYY-MM-DD) | ^\d{4}-\d{2}-\d{2}$ | Format only — doesn't validate real dates |
| Time (24-hour HH:MM) | ^([01]\d|2[0-3]):[0-5]\d$ | 00:00 to 23:59 |
| URL slug | ^[a-z0-9]+(?:-[a-z0-9]+)*$ | Lowercase words joined by single hyphens |
| Digits only | ^\d+$ | One or more digits, nothing else |
| Letters only | ^[A-Za-z]+$ | ASCII letters only |
| Username | ^\w{3,16}$ | 3–16 letters, digits, or underscores |
| US phone (loose) | ^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$ | Allows (), spaces, dots, or dashes |
| Strong password | ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$ | 8+ chars with lower, upper, and a digit (lookaheads) |
| Leading/trailing space | ^\s+|\s+$ | Use to trim whitespace from both ends |
A caution: patterns like these validate format, not meaning. A string can match the email pattern and still not be a real, deliverable address — for anything critical, validate format with regex but confirm the value another way (e.g. a verification email).
Related tools