Regex Pattern Library
v1.0.0Browse a curated library of common regular expression patterns organised by category.
32 patterns found
Email Address
ValidationBasic RFC-5321-compatible email validation.
/^[\w.%+\-]+@[\w.\-]+\.[a-zA-Z]{2,}$/iURL (http/https)
URLMatch http and https URLs.
/^https?:\/\/[\w\-]+(\.[\w\-]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])?$/iIPv4 Address
IPMatch valid IPv4 addresses.
/^(25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)(\.(25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)){3}$/IPv6 Address
IPMatch full-form IPv6 addresses.
/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/iISO 8601 Date
DateYYYY-MM-DD format.
/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/International Phone
PhoneE.164 international phone number format.
/^\+?[1-9]\d{1,14}$/Hex Color
ValidationCSS hex color codes (3, 6, or 8 hex digits with #).
/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/iGerman Postal Code
PostalGerman 5-digit postal code.
/^[0-9]{5}$/US ZIP Code
PostalUS 5-digit or ZIP+4 postal code.
/^\d{5}(-\d{4})?$/Credit Card Number
ValidationMajor card types: Visa, Mastercard, Amex, Discover.
/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|6(?:011|5[0-9]{2})[0-9]{12})$/UUID v4
ValidationRFC 4122 UUID version 4.
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iURL Slug
URLLowercase alphanumeric slug with hyphens.
/^[a-z0-9]+(?:-[a-z0-9]+)*$/Strong Password
ValidationMinimum 12 chars, upper+lower+digit+special.
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w]).{12,}$/Username
Validation3–20 chars, starts with letter, allows _ and -.
/^[a-zA-Z][a-zA-Z0-9_\-]{2,19}$/HTML Tag
ParsingMatch opening HTML tags.
/<([a-zA-Z][a-zA-Z0-9]*)\b[^>]*>/gIBAN
ValidationBasic IBAN structure validation.
/^[A-Z]{2}\d{2}[A-Z0-9]{1,30}$/MAC Address
NetworkMAC address with : or - separator.
/^([0-9A-Fa-f]{2}[:\-]){5}[0-9A-Fa-f]{2}$/iCIDR Notation
NetworkIPv4 CIDR block notation.
/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\/([0-9]|[1-2][0-9]|3[0-2])$/Semantic Version
Validationsemver 2.0.0 specification.
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z][\w]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z][\w]*))*))?(?:\+([\w]+(\.[\w]+)*))?$/JWT Token
ValidationThree-part base64url JWT structure.
/^[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]*$/Unix Timestamp
Date10-digit Unix epoch timestamp (1973–2286).
/^[1-9]\d{8,9}$/Docker Image Name
ParsingDocker image with optional registry, namespace and tag.
/^(?:[a-z0-9]+(?:[._\-][a-z0-9]+)*\/)*[a-z0-9]+(?:[._\-][a-z0-9]+)*(?::[\w.\-]+)?$/CSS Class Name
ParsingValid CSS class identifier.
/^\.?-?[_a-zA-Z]+[_a-zA-Z0-9\-]*$/Unix File Path
ParsingAbsolute Unix file path.
/^(\/[^\/\x00]+)+\/?$/Windows File Path
ParsingAbsolute Windows file path.
/^[a-zA-Z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*$/iYouTube Video ID
URL11-character YouTube video identifier.
/^[a-zA-Z0-9_\-]{11}$/Base64 String
EncodingStandard Base64 encoded string.
/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{4})$/Hexadecimal String
EncodingHexadecimal digits, optionally prefixed with 0x.
/^(0x)?[0-9a-fA-F]+$/iJSON Object (starts/ends with {})
ParsingRough detection that a string looks like a JSON object.
/^\s*\{[\s\S]*\}\s*$/Time HH:MM
Date24-hour time format.
/^([01]\d|2[0-3]):[0-5]\d$/Currency Amount
NumbersUS currency format with optional cents.
/^-?\d{1,3}(?:,?\d{3})*(?:\.\d{2})?$/US Social Security Number
ValidationUS SSN format (dashes required).
/^(?!000|9\d{2}|666)\d{3}-(?!00)\d{2}-(?!0000)\d{4}$/