Regex Pattern Library

Common regex patterns ready to copy and use.

Ready-to-use patterns

Email

Matches valid email addresses

^[\w.-]+@[a-zA-Z\d.-]+\.[a-zA-Z]{2,}$

URL

Matches HTTP/HTTPS URLs

^https?:\/\/[\w.-]+\.[a-zA-Z]{2,}[\/\w.-]*$

Phone (US)

US phone number formats

^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$

Phone (Intl)

International phone (E.164)

^\+?[1-9]\d{1,14}$

Credit Card

Visa, MasterCard, Amex

^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13})$

IPv4

IPv4 address

^(?:(?: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]?)$

Hex Color

CSS hex color

^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$

Alphanumeric

Letters and numbers only

^[a-zA-Z0-9]+$

Letters Only

Letters only

^[a-zA-Z]+$

Numbers Only

Digits only

^\d+$

No Whitespace

No whitespace characters

^\S+$

Slug

URL slug format

^[a-z0-9]+(?:-[a-z0-9]+)*$

Username

Alphanumeric username

^[a-zA-Z][a-zA-Z0-9_]{2,15}$

Strong Password

Min 8 chars, upper, lower, digit, special

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$

Medium Password

Min 6 chars, upper, lower, digit

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{6,}$

Date (YYYY-MM-DD)

ISO date format

^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$

Date (MM/DD/YYYY)

US date format

^(?:0[1-9]|1[0-2])\/(?:0[1-9]|[12]\d|3[01])\/\d{4}$

Time (24h)

24-hour time

^(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?$

Time (12h)

12-hour time

^(?:0?[1-9]|1[0-2]):[0-5]\d\s?(?:AM|PM|am|pm)$

HTML Tag

HTML opening/closing tags

<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)

CSS Class

CSS class selector

\.[a-zA-Z_][a-zA-Z0-9_-]*

JS Variable

Valid JS variable name

^[a-zA-Z_$][a-zA-Z0-9_$]*$

UUID

UUID v4 format

^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$

💡 Use the Regex Tester to test these patterns

Your data never leaves your browser • No cookies • Works offline after your first visit

Press ? for keyboard shortcuts

We use minimal, privacy-focused cookies to improve your experience. Our developer tools process all data locally — we never store your content. Learn more