Regex pattern library
12 curated, production-ready regular expressions. Each comes with a plain-English explanation, matching and non-matching examples, edge cases that bite people, and ready-to-paste code in 13 languages.
Validation
4 patternsPatterns that answer 'is this input shaped correctly' for things like email addresses, URLs, and IPs.
Email address
email regexPractical, permissive email validator that catches typos without rejecting real addresses.
/^[^\s@]+@[^\s@]+\.[^\s@]+$/iURL (HTTP/HTTPS)
url regexPractical HTTP/HTTPS URL validator that accepts real URLs and rejects the obvious junk.
/^https?:\/\/[^\s/$.?#].[^\s]*$/iIPv4 address
ipv4 regexStrict IPv4 that rejects out-of-range octets like 999.999.999.999.
/^(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)$/US phone number
us phone number regexUS phone number that accepts every common formatting people actually type.
/^(?:\+?1[\s-.]?)?(?:\(\d{3}\)|\d{3})[\s-.]?\d{3}[\s-.]?\d{4}$/Format
5 patternsPatterns that match well-defined data formats — dates, versions, identifiers.
UUID v4
uuid regexRFC 4122 UUID version 4 — the random-bytes variant nearly every database uses.
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iISO 8601 date / datetime
iso 8601 date regexISO 8601 dates and optional datetimes with timezone, the format every modern JSON API speaks.
/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/Semantic version
semver regexThe official semver.org reference regex — major.minor.patch with optional pre-release and build metadata.
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/Hex color
hex color regexCSS hex color in 3-, 6-, or 8-character (with alpha) form.
/^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/iURL slug (kebab-case)
slug regexLowercase alphanumerics with single hyphens between words — the canonical URL slug shape.
/^[a-z0-9]+(?:-[a-z0-9]+)*$/Extraction
1 patternPatterns for pulling structured tokens out of running text — JWTs, IDs, references.
Security
2 patternsPatterns for security-adjacent checks — credit cards, password strength.
Credit card (shape-only)
credit card regexShape check for credit-card numbers — 13 to 19 digits with optional spaces/hyphens.
/^(?:\d[ -]*?){13,19}$/Strong password
password regex12+ characters with upper, lower, digit, and symbol — the familiar 'complex password' rule.
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_])[A-Za-z\d\W_]{12,}$/Not finding what you need?
The library covers the most-Googled patterns. For one-off regexes, describe what you want to match in plain English and the AI generator will build it for you.
Open the AI generator