Pragmatic email address validation.
^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$matches: jane.doe@example.co.ukno match: jane@@example
HTTP or HTTPS absolute URL.
^https?:\/\/[^\s/$.?#].[^\s]*$matches: https://example.com/path?q=1no match: ftp://example.com
Fully-qualified domain name.
^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$matches: sub.example.comno match: -bad.com
Lowercase, hyphen-separated URL slug.
^[a-z0-9]+(?:-[a-z0-9]+)*$matches: my-page-titleno match: My Page
TCP/UDP port 1–65535.
^(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{0,3})$matches: 8080no match: 70000
Dotted-quad IPv4 address.
^(?:(?:25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})\.){3}(?:25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})$matches: 192.168.0.1no match: 256.1.1.1
Common IPv6 forms incl. :: compression.
^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|::([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4})$matches: 2001:db8::ff00:42:8329no match: 1200::AB00::1234
Colon or hyphen separated MAC address.
^(?:[0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}$matches: 01:23:45:67:89:ABno match: 0123.4567.89AB
North American phone number with optional formatting.
^(?:\+?1[-.\s]?)?\(?[2-9][0-9]{2}\)?[-.\s]?[0-9]{3}[-.\s]?[0-9]{4}$matches: (415) 555-0132no match: 12-3
International phone (E.164)contact E.164 international number.
^\+[1-9]\d{1,14}$matches: +442071838750no match: 0044 20 7183
ISO date (YYYY-MM-DD)datetime Calendar date in ISO 8601 format.
^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$matches: 2026-05-30no match: 2026-13-01
24-hour clock time.
^([01]\d|2[0-3]):[0-5]\d$matches: 23:59no match: 24:00
ISO 8601 timestamp with optional zone.
^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?$matches: 2026-05-30T14:00:00Zno match: 2026/05/30 14:00
3-, 6-, or 8-digit hex color.
^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$matches: #1e90ffno match: #12g
RFC 4122 version-4 UUID.
^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$matches: f47ac10b-58cc-4372-a567-0e02b2c3d479no match: not-a-uuid
Alphanumeric/underscore, 3–16 chars.
^[a-zA-Z0-9_]{3,16}$matches: cool_user99no match: ab
8+ chars with lower, upper, digit and symbol.
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z0-9]).{8,}$matches: Str0ng!Passno match: password
Visa / MasterCard / Amex / Discover numbers (no spaces).
^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|6(?:011|5[0-9]{2})[0-9]{12})$matches: 4111111111111111no match: 1234567890123456
5-digit ZIP with optional +4.
^\d{5}(?:-\d{4})?$matches: 94103-1234no match: 9410
UK postal code (uppercase).
^[A-Z]{1,2}\d[A-Z\d]?\s?\d[A-Z]{2}$matches: SW1A 1AAno match: 12345
Canadian postal codepostal Canadian alphanumeric postal code.
^[A-Za-z]\d[A-Za-z]\s?\d[A-Za-z]\d$matches: K1A 0B1no match: K1A0B
Semantic version with optional pre-release/build.
^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z-.]+)?(?:\+[0-9A-Za-z-.]+)?$matches: 1.2.3-rc.1+build.5no match: 1.2
Standard Base64 (with padding).
^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$matches: SGVsbG8=no match: SGVsbG8*
Three base64url segments separated by dots.
^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*$matches: aaa.bbb.cccno match: aaa.bbb
Opening or closing HTML tag.
<\/?[a-zA-Z][a-zA-Z0-9]*\b[^>]*>matches: <div class="x">no match: plain text
Leading/trailing whitespacetext Whitespace at the start or end of a string.
^\s+|\s+$matches: trim me no match: no-space
Runs of two or more whitespace characters.
\s{2,}matches: a bno match: a b
One or more leading zeros before a digit.
^0+(?=\d)matches: 007no match: 7
Optional sign followed by digits.
^-?\d+$matches: -42no match: 4.2
Signed integer or decimal.
^-?\d*\.?\d+$matches: 3.14no match: 3.1.4
US currency with optional $ and thousands separators.
^\$?\d{1,3}(?:,\d{3})*(?:\.\d{2})?$matches: $1,299.00no match: 1.2.3
Social-media style hashtag.
#[A-Za-z0-9_]+matches: #regex101no match: # spaced