Top 50 Regex Patterns Developers Actually Use
Copy-paste ready regular expressions for validation, parsing, and text manipulation. Tested and battle-proven patterns for everyday development.
Email Address
Validates email format
^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,}$URL
Matches HTTP/HTTPS URLs
^(https?:\/\/)?([\w.-]+)\.([a-z]{2,})(\/\S*)?$Phone (US)
US phone number formats
^\+?1?[-.\s]?$$?\d{3}$$?[-.\s]?\d{3}[-.\s]?\d{4}$Phone (International)
E.164 international format
^\+?[1-9]\d{1,14}$Date (YYYY-MM-DD)
ISO date format
^\d{4}-\d{2}-\d{2}$Date (MM/DD/YYYY)
US date format
^\d{2}\/\d{2}\/\d{4}$Time (24hr)
24-hour time format
^([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$IPv4 Address
Valid IPv4 address
^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$IPv6 Address
Full IPv6 address
^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$Hex Color
CSS hex color code
^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$Username
Alphanumeric, 3-16 chars
^[a-zA-Z0-9_]{3,16}$Password (Strong)
Min 8 chars, upper, lower, number, special
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$Credit Card
16-digit card number
^\d{4}[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}$SSN
US Social Security Number
^\d{3}-\d{2}-\d{4}$ZIP Code (US)
5 or 9 digit ZIP
^\d{5}(-\d{4})?$Postal Code (UK)
UK postcode format
^[A-Z]{1,2}\d[A-Z\d]? ?\d[A-Z]{2}$UUID
Standard UUID format
^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$Slug
URL-friendly slug
^[a-z0-9]+(?:-[a-z0-9]+)*$HTML Tag
Matches HTML tags
<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)Whitespace
Only whitespace
^\s*$Non-Empty
At least one non-whitespace
\S+Digits Only
Only numbers
^\d+$Letters Only
Only letters
^[a-zA-Z]+$Alphanumeric
Letters and numbers only
^[a-zA-Z0-9]+$No Special Chars
Letters, numbers, spaces
^[a-zA-Z0-9 ]+$Currency (USD)
US dollar format
^\$?\d{1,3}(,\d{3})*(\.\d{2})?$Percentage
Number with percent sign
^\d+(\.\d+)?%$File Extension
Extract file extension
\.([a-zA-Z0-9]+)$Image File
Common image extensions
\.(jpg|jpeg|png|gif|webp|svg)$Domain Name
Valid domain name
^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$MAC Address
Network MAC address
^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$Latitude
Valid latitude
^-?([1-8]?\d(\.\d+)?|90(\.0+)?)$Longitude
Valid longitude
^-?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$Markdown Link
Extract markdown links
\[([^\]]+)\]$$([^)]+)$$YouTube URL
Extract YouTube video ID
(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)Twitter Handle
Twitter/X username
^@?[a-zA-Z0-9_]{1,15}$Hashtag
Social media hashtag
#[a-zA-Z0-9_]+JSON String
Valid JSON string
"([^"\\]|\\.)*"Word Boundary
Match whole words
\b\w+\bDuplicate Words
Find repeated words
\b(\w+)\s+\1\bLeading/Trailing Space
Trim whitespace
^\s+|\s+$Multiple Spaces
Two or more spaces
\s{2,}Empty Lines
Blank lines
^\s*$\nSentence
Match sentences
[A-Z][^.!?]*[.!?]Camel Case
camelCase format
^[a-z]+([A-Z][a-z]+)*$Pascal Case
PascalCase format
^([A-Z][a-z]+)+$Snake Case
snake_case format
^[a-z]+(_[a-z]+)*$Kebab Case
kebab-case format
^[a-z]+(-[a-z]+)*$Base64
Base64 encoded string
^[A-Za-z0-9+/]+=*$JWT Token
JSON Web Token format
^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$