Regex Pattern Library
A searchable library of 50+ common regex patterns. Browse by category, test against sample input, and copy patterns for email, URL, IP, dates, passwords, and more.
45 patterns
Validates standard email addresses
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$Example: user@example.com
E.164 international phone format
^\+?[1-9]\d{1,14}$Example: +14155552671
US phone number formats
^\(?\d{3}\)?[-\s.]?\d{3}[-\s.]?\d{4}$Example: (415) 555-2671
Matches HTTP and HTTPS URLs
^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$Example: https://example.com/path?q=1
Validates IPv4 addresses
^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$Example: 192.168.1.1
Full IPv6 address format
^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
Valid domain names
^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$Example: sub.example.com
MAC address with colons or dashes
^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$Example: 00:1B:44:11:3A:B7
URL-friendly slug format
^[a-z0-9]+(?:-[a-z0-9]+)*$
Example: my-blog-post
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})$Example: 4111111111111111
US Social Security Number format
^\d{3}-\d{2}-\d{4}$Example: 123-45-6789
Min 8 chars, upper, lower, digit, special
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$Example: Str0ng@Pass
JSON Web Token format
^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_.+\/=]*$
Example: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIn0.sig
Hex API key 32-64 characters
^[a-fA-F0-9]{32,64}$Example: a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4
ISO 8601 date format
^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$Example: 2024-01-15
US date format
^(?:0[1-9]|1[0-2])\/(?:0[1-9]|[12]\d|3[01])\/\d{4}$Example: 01/15/2024
24-hour time format
^(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?$
Example: 14:30:00
Full ISO 8601 datetime
^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$Example: 2024-01-15T14:30:00Z
Match paired HTML tags
<([a-zA-Z][a-zA-Z0-9]*)\b[^>]*>.*?<\/\1>
Example: <div>content</div>
3 or 6 digit hex color
^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$Example: #FF5733
SemVer format
^\d+\.\d+\.\d+(?:-[\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*)?(?:\+[\da-zA-Z-]+)?$
Example: 1.2.3-beta.1
UUID version 4 format
^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$Example: 123e4567-e89b-42d3-a456-426614174000
Simple JSON string key-value pairs
"([^"]+)"\s*:\s*"([^"]*)"
Example: "key": "value"
CSS class selectors
\.[a-zA-Z_][a-zA-Z0-9_-]*
Example: .my-class
JavaScript/TypeScript import
^import\s+.*\s+from\s+['"]([^'"]+)['"]
Example: import x from 'module'
String with only whitespace
^\s+$
Example:
String without whitespace
^\S+$
Example: nospaces
Only letters and numbers
^[a-zA-Z0-9]+$
Example: abc123
No digits allowed
^[^\d]+$
Example: Hello World!
Find repeated consecutive words
\b(\w+)\s+\1\b
Example: the the
Markdown hyperlink syntax
\[([^\]]+)\]\(([^)]+)\)
Example: [text](url)
Social media hashtag
#[a-zA-Z0-9_]+
Example: #coding
Twitter/social media mention
@[a-zA-Z0-9_]{1,15}Example: @username
Positive or negative integer
^-?\d+$
Example: -42
Decimal floating point
^-?\d+\.\d+$
Example: 3.14
Scientific notation format
^-?\d+\.?\d*[eE][+-]?\d+$
Example: 1.5e10
Percentage value
^\d+(?:\.\d+)?%$
Example: 99.5%
US dollar format
^\$\d{1,3}(?:,\d{3})*(?:\.\d{2})?$Example: $1,234.56
Extract file extension
\.[a-zA-Z0-9]+$
Example: document.pdf
Common image extensions
\.(?:jpg|jpeg|png|gif|bmp|svg|webp)$
Example: photo.jpg
Unix-style file path
^\/(?:[^\/]+\/)*[^\/]+$
Example: /usr/local/bin/node
Windows file path
^[a-zA-Z]:\\(?:[^\\]+\\)*[^\\]+$
Example: C:\Users\file.txt
Base64 encoded string
^[A-Za-z0-9+\/]+={0,2}$Example: SGVsbG8gV29ybGQ=
32-char hex MD5
^[a-fA-F0-9]{32}$Example: d41d8cd98f00b204e9800998ecf8427e
64-char hex SHA-256
^[a-fA-F0-9]{64}$Example: e3b0c44298fc1c149afbf4c8996fb924...
How to Use the Regex Pattern Library
- Search for patterns by name or description using the search bar.
- Filter by category: Contact, Network, Security, Date, Code, Text, Numbers, Files, Encoding.
- Optionally enter a test input to see which patterns match.
- Click the copy button to copy any regex pattern.
- Each pattern includes an example string for quick reference.
About Regex Pattern Library
Regular expressions are powerful pattern-matching tools used across programming languages for text validation, search, and extraction. This library provides 50+ pre-built, tested regex patterns organized by category. Each pattern includes a description, example input, and the ability to test against your own input. Categories cover common validation needs like email addresses, URLs, IP addresses, phone numbers, dates, passwords, file paths, and code patterns. All patterns use standard regex syntax compatible with JavaScript, Python, and most other languages.
Frequently Asked Questions
Most patterns cover common cases and are suitable for basic validation. For production use, especially with security-sensitive data like email addresses, consider using established validation libraries that handle edge cases and internationalization.
The patterns use standard regex syntax that works in JavaScript, Python, PHP, Java, Go, and most modern languages. Some features like lookaheads may have limited support in older regex engines.