Regex Playground
Build, test, and understand regular expressions visually
Quick Reference
.Any character\dDigit\wWord char\sWhitespace^Start$End*0 or more+1 or more?Optional[abc]Character set(ab)Group|OrPattern Library
Email (Simple)
EmailBasic email validation pattern
/^[^\s@]+@[^\s@]+\.[^\s@]+$/[email protected]test.name+tag@domain...Email (RFC 5322)
EmailComprehensive RFC 5322 compliant email pattern
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/HTTP/HTTPS URL
URLMatches HTTP and HTTPS URLs
/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/https://example.comhttp://www.test.com/...Any URL
URLMatches any URL including ftp, file, etc.
/^(?:[a-z][a-z0-9+.-]*:)?\/\/(?:(?:[a-z0-9-._~%!$&'()*+,;=]+|\[[a-f0-9:.]+\])@)?(?:[a-z0-9-._~%!$&'()*+,;=]+|\[[a-f0-9:.]+\])(?::[0-9]+)?(?:\/[a-z0-9-._~%!$&'()*+,;=:@]*)*(?:\?[a-z0-9-._~%!$&'()*+,;=:@\/?]*)?(?:#[a-z0-9-._~%!$&'()*+,;=:@\/?]*)?$/ftp://files.example....https://sub.domain.c...UUID v4
UUIDMatches UUID version 4 format
/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/550e8400-e29b-41d4-a...6ba7b810-9dad-11d1-8...UUID (Any Version)
UUIDMatches any UUID version
/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/550e8400-e29b-41d4-a...6ba7b810-9dad-11d1-8...Phone (International)
PhoneInternational phone number with country code
/^\+(?:[0-9] ?){6,14}[0-9]$/+1 555 123 4567+44 20 7123 4567Phone (US)
PhoneUS phone number in various formats
/^(?:\+?1[-.\s]?)?\(?([0-9]{3})\)?[-.\s]?([0-9]{3})[-.\s]?([0-9]{4})$/(555) 123-4567555-123-4567Date (ISO 8601)
DateISO 8601 date format (YYYY-MM-DD)
/^([0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])$/2024-01-151999-12-31Date (US Format)
DateUS date format (MM/DD/YYYY)
/^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])\/([0-9]{4})$/01/15/202412/31/1999Date (EU Format)
DateEuropean date format (DD/MM/YYYY)
/^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[0-2])\/([0-9]{4})$/15/01/202431/12/1999Time (24-hour)
Time24-hour time format (HH:MM)
/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/14:3023:59Time (12-hour)
Time12-hour time with AM/PM
/^(0?[1-9]|1[0-2]):[0-5][0-9]\s?(?:[AP]M|[ap]m)?$/2:30 PM11:59amInteger
NumberPositive and negative integers
/^-?[0-9]+$/-420Decimal Number
NumberNumbers with optional decimal places
/^-?[0-9]+(?:\.[0-9]+)?$/-3.140Percentage
NumberPercentage value (0-100)
/^(?:100|[1-9]?[0-9])%?$/50%100URL Slug
TextURL-friendly slug (lowercase, hyphens)
/^[a-z0-9]+(?:-[a-z0-9]+)*$/my-blog-postproduct-123Username
TextAlphanumeric username with underscores
/^[a-zA-Z][a-zA-Z0-9_]{2,15}$/john_doeUser123Hashtag
TextSocial media hashtag
/^#[a-zA-Z0-9_]+$/#trending#HelloWorldStrong Password
ValidationAt least 8 chars, uppercase, lowercase, number, special char
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/P@ssw0rd!Str0ng#PassUS Zip Code
ValidationUS ZIP code (5 digits or ZIP+4)
/^[0-9]{5}(?:-[0-9]{4})?$/1234590210-1234UK Postcode
ValidationUK postcode format
/^[A-Z]{1,2}[0-9][A-Z0-9]? ?[0-9][A-Z]{2}$/SW1A 1AAM1 1AAIPv4 Address
WebIPv4 address format
/^(?:(?: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]?)$/192.168.1.1127.0.0.1Domain Name
WebValid domain name without protocol
/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$/example.comsub.domain.co.ukHTML Tag
WebMatches HTML tags (opening or closing)
/<\/?[a-z][\s\S]*?>/<div></span>JSON String
DataQuoted JSON string with escape sequences
/^"(?:[^"\\]|\\.)*"$/"hello""line\nbreak"Base64 String
DataBase64 encoded string
/^[A-Za-z0-9+\/]+=*$/SGVsbG8gV29ybGQ=YWJjMTIzHex Color
DataHexadecimal color code (3, 6, or 8 digits)
/^#(?:[0-9a-fA-F]{3}){1,2}$|^#(?:[0-9a-fA-F]{4}){1,2}$/#fff#FF5733Credit Card Number
SecurityCommon credit card number formats
/^(?:[0-9]{4}[-\s]?){3}[0-9]{4}$/1234-5678-9012-34564111 1111 1111 1111JWT Token
SecurityJSON Web Token format
/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/eyJhbGciOiJIUzI1NiIs...API Key (Generic)
SecurityCommon API key formats (32-64 hex chars)
/^[a-fA-F0-9]{32,64}$/a1b2c3d4e5f6a1b2c3d4...1234567890abcdef1234...
