A curated collection of production-ready regular expressions.
Search, filter, and copy patterns for your next project.
Validate email addresses with RFC-compliant regex pattern.
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
At least 8 chars, 1 uppercase, 1 lowercase, 1 number, 1 special char.
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$
Matches valid IPv4 addresses.
^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$
Matches a version 4 UUID.
^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
Matches dates in YYYY-MM-DD format.
^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$
Matches valid URL slugs (kebab-case).
^[a-z0-9]+(?:-[a-z0-9]+)*$
Matches hex color codes (#FFF or #FFFFFF).
^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$
Matches opening and closing HTML tags.
<[^>]+>
Matches a Twitter handle (username).
^@?(\w){1,15}$
Matches a simple flat JSON object (basic approximation).
\{\s*"[^"]+"\s*:\s*(?:"[^"]+"|\d+|true|false|null)\s*\}
Matches a CSV field, handling quotes.
(?:^|,)(?:"([^"]*(?:""[^"]*)*)"|([^",]*))
Finds duplicate words in a sentence.
\b(\w+)\s+\1\b
Matches whitespace at the end of lines.
[ \t]+$
Matches the position before capital letters to split CamelCase.
(?<=[a-z])(?=[A-Z])
Matches major credit cards (Visa, MasterCard, Amex, Discover).
^(?: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 US Social Security Numbers (XXX-XX-XXXX).
^(?!000|666|9\d\d)\d{3}-(?!00)\d{2}-(?!0000)\d{4}$
Matches US phone numbers in various formats.
^\(?([2-9][0-8][0-9])\)?[-. ]?([2-9][0-9]{2})[-. ]?([0-9]{4})$
Matches standard IPv6 addresses.
^(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}$
Matches identifiers assigned to network interfaces.
^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$
Matches SemVer 2.0.0 strings.
^v?(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-]+)*))?$
Matches typical Docker image names.
^(?:(?=[^:\/]{1,253})(?!-)[a-z0-9-]{1,63}(?<!-)(?:\.(?!-)[a-z0-9-]{1,63}(?<!-))*(?::[0-9]{1,5})?/)?((?![._-])(?:[a-z0-9._-]*)(?<![._-])(?:\/(?![._-])[a-z0-9._-]*(?<![._-]))*)(?::(?![.-])[a-zA-Z0-9_.-]{1,128})?$
Matches Amazon Resource Names.
^arn:(?:aws|aws-cn|aws-us-gov|aws-iso|aws-iso-b):[a-z0-9-]*:[a-z0-9-]*:[0-9]{12}:[a-zA-Z0-9-_/]+$
Matches logical parts of a standard Cron schedule.
^(\*|([0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9])|\*\/([0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9])) (\*|([0-9]|1[0-9]|2[0-3])|\*\/([0-9]|1[0-9]|2[0-3])) (\*|([1-9]|1[0-9]|2[0-9]|3[0-1])|\*\/([1-9]|1[0-9]|2[0-9]|3[0-1])) (\*|([1-9]|1[0-2])|\*\/([1-9]|1[0-2])) (\*|([0-6])|\*\/([0-6]))$
Matches a 32-character hexadecimal MD5 hash.
^[a-fA-F0-9]{32}$
Matches a 64-character hexadecimal SHA-256 hash.
^[a-fA-F0-9]{64}$
Matches the structure of a JSON Web Token.
^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+$
Matches valid Base64 encoded strings.
^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$
Matches a price in USD, with optional cents.
^\$?\d{1,3}(?:,\d{3})*(?:\.\d{2})?$
Matches time in HH:MM format (24-hour).
^(?:[01]\d|2[0-3]):[0-5]\d$
Matches a percentage value (0-100), optional decimals.
^(?:100(?:\.0+)?|\d{1,2}(?:\.\d+)?|0(?:\.\d+)?)\%?$
Matches decimal latitude and longitude pairs.
^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$
Matches common image file extensions.
\.(jpg|jpeg|png|gif|bmp|webp|svg)$
Matches a Windows file path (drive letter + path).
^[a-zA-Z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*$
Matches an absolute path on Linux/Unix systems.
^\/(?:[^\/]+\/?)*$
Matches the 11-character YouTube video identifier.
^[a-zA-Z0-9_-]{11}$