Email address
Matches a standard email address. Pragmatic pattern suitable for form validation.
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$Example match: user.name@example.com
URL (http/https)
Matches HTTP and HTTPS URLs with optional path, query, and fragment.
^https?:\/\/[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=]*$Example match: https://example.com/path?q=1
Slug (URL-friendly)
Lowercase words separated by single hyphens, as used in URL slugs.
^[a-z0-9]+(?:-[a-z0-9]+)*$Example match: my-blog-post-2024
IPv4 address
Matches a valid IPv4 address with each octet between 0 and 255.
^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$Example match: 192.168.1.1
MAC address
Matches a MAC address using colon or hyphen separators.
^(?:[0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}$Example match: 01:23:45:67:89:AB
US phone number
Matches US phone numbers with optional country code and common separators.
^\+?1?[\s.-]?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$Example match: +1 (555) 123-4567
Indian mobile number
Matches a 10-digit Indian mobile number starting 6-9, with optional +91.
^(?:\+91[\s-]?)?[6-9]\d{9}$Example match: +91 9876543210
Strong password
At least 8 chars with one lowercase, one uppercase, one digit, and one special char.
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$Example match: Passw0rd!
Username
Alphanumeric and underscore, 3 to 16 characters.
^[a-zA-Z0-9_]{3,16}$Example match: john_doe_99
Hex color
Matches 3-digit or 6-digit hexadecimal color codes.
^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$Example match: #6366f1
Date (YYYY-MM-DD)
Matches ISO 8601 style dates. Does not validate day-per-month exactness.
^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$Example match: 2024-02-29
Time (24-hour HH:MM)
Matches 24-hour clock time from 00:00 to 23:59.
^(?:[01]\d|2[0-3]):[0-5]\d$Example match: 14:30
Time (12-hour with AM/PM)
Matches 12-hour time with an AM or PM suffix.
^(?:1[0-2]|0?[1-9]):[0-5]\d\s?(?:[AaPp][Mm])$Example match: 2:30 PM
Credit card (major issuers)
Matches Visa, Mastercard, American Express, and Discover card numbers.
^(?: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})$Example match: 4111111111111111
Postal code (US ZIP)
Matches a 5-digit US ZIP code with an optional 4-digit extension.
^\d{5}(?:-\d{4})?$Example match: 90210-1234
Indian PIN code
Matches a 6-digit Indian postal PIN code not starting with zero.
^[1-9][0-9]{5}$Example match: 560001
Whitespace (leading/trailing)
Matches leading and trailing whitespace, useful for trimming.
^\s+|\s+$Example match: hello
Number (integer or decimal)
Matches a signed integer or decimal number.
^-?\d+(?:\.\d+)?$Example match: -42.75
HTML tag
Matches opening and closing HTML tags with optional attributes.
<\/?[a-zA-Z][a-zA-Z0-9]*\b[^>]*>Example match: <div class="box">
IPv6 address
Matches a fully expanded IPv6 address (eight groups of hex).
^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$Example match: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
100% Private
This pattern library runs entirely in your browser. Nothing uploaded.