Common Regex Patterns — Ready-to-Use Regular Expressions

A searchable library of 30+ pre-built regex patterns for the most common tasks. Email validation, phone numbers, URLs, dates, passwords, and more. Click any pattern to load it into the tester with sample data.

Stop Reinventing the Wheel

Most regex tasks have been solved thousands of times. Need to validate an email? Match a phone number? Extract dates from text? Instead of writing a pattern from scratch and debugging edge cases, start with a proven pattern from this library. Load it, test it against your data, customize if needed, and copy it into your code.

Patterns for Every Use Case

The library covers 7 categories: contact validation (email, phone), web (URLs, domains, IPs), numbers (integers, decimals, currency), dates and times (ISO, US format, 24-hour), input validation (passwords, usernames, credit cards), text processing (HTML tags, whitespace, duplicates), and developer patterns (imports, TODOs, semver, JSON keys).

Each Pattern Includes Sample Data

When you click "Load Pattern," the tool loads both the regex and a test string with matching and non-matching examples. This immediately shows you what the pattern catches and what it misses. Modify the test string to add your own data and verify the pattern works for your specific case.

Browse and search patterns below.

/
/g
✅ Valid pattern
No matches

Common Regex Patterns

📧 Email & Contact

Email Address
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Standard email validation
Phone (US)
^(\+1)?[-.\s]?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$
US phone with optional country code
Phone (International)
^\+?[1-9]\d{1,14}$
E.164 international phone format

🌐 URLs & Web

URL (HTTP/HTTPS)
https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)
Match HTTP/HTTPS URLs
Domain Name
^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$
Valid domain names
IPv4 Address
^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$
Standard IPv4 address
IPv6 Address
^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$
Full IPv6 address
Slug (URL path)
^[a-z0-9]+(?:-[a-z0-9]+)*$
URL-safe slug format

🔢 Numbers & Math

Integer
^-?\d+$
Positive or negative whole number
Decimal Number
^-?\d*\.?\d+$
Number with optional decimal
Currency (USD)
^\$?\d{1,3}(,\d{3})*(\.\d{2})?$
US dollar format ($1,234.56)
Percentage
^-?\d+(\.\d+)?%$
Percentage value
Hex Number
^0x[0-9a-fA-F]+$
Hexadecimal number

📅 Dates & Times

Date (YYYY-MM-DD)
^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
ISO 8601 date format
Date (MM/DD/YYYY)
^(0[1-9]|1[0-2])\/(0[1-9]|[12]\d|3[01])\/\d{4}$
US date format
Time (24h)
^([01]\d|2[0-3]):([0-5]\d)(:([0-5]\d))?$
24-hour time (HH:MM or HH:MM:SS)
ISO 8601 Datetime
^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})?$
Full ISO datetime

🔐 Validation

Password (Strong)
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$
8+ chars, upper, lower, digit, symbol
Username
^[a-zA-Z0-9_-]{3,20}$
3-20 chars, letters, numbers, underscores, hyphens
Credit Card
^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13})$
Visa, Mastercard, Amex
SSN (US)
^\d{3}-?\d{2}-?\d{4}$
US Social Security Number format
ZIP Code (US)
^\d{5}(-\d{4})?$
US ZIP code with optional +4
Hex Color
^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$
HEX color code

📝 Text & Strings

HTML Tag
<([a-zA-Z][a-zA-Z0-9]*)\b[^>]*>(.*?)<\/\1>
Match HTML tags with content
Whitespace Trim
^\s+|\s+$
Leading and trailing whitespace
Duplicate Words
\b(\w+)\s+\1\b
Find repeated consecutive words
Markdown Link
\[([^\]]+)\]\(([^)]+)\)
Match [text](url) markdown links
Empty Lines
^\s*$
Match blank/empty lines

🖥️ Code & Dev

CSS Hex Color
#([0-9a-fA-F]{3}){1,2}\b
Match CSS hex colors
JSON Key
"([^"]+)"\s*:
Match JSON object keys
Import Statement
import\s+.*\s+from\s+['"](.+)['"]
ES6 import statements
TODO Comment
\/\/\s*TODO:?\s*(.*)
Match TODO comments
Semver
^(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-]+)*))?$
Semantic versioning
File Extension
\.([a-zA-Z0-9]+)$
Extract file extension