Elysia Tools
Navigation
Development
Regular Expression Examples: Format and Boundary Tests
Test usernames, dates and IPv4 patterns with positive and negative examples.
Samples
Entries inside this sample collection
Email Address
Validate email addresses format
Tags
regex, regular-expression, pattern, validation, email, contact
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$URL / Web Address
Match HTTP/HTTPS URLs
Tags
regex, regular-expression, pattern, validation, url, web, http, https
^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$IPv4 Address
Validate IPv4 addresses
Tags
regex, regular-expression, pattern, validation, ip, ipv4, network
^(?:(?: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]?)$IPv6 Address
Validate IPv6 addresses
Tags
regex, regular-expression, pattern, validation, ip, ipv6, network, advanced
^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]+|::(ffff(:0{1,4})?:)?((25[0-5]|(2[0-4]|1?[0-9])?[0-9])\.){3}(25[0-5]|(2[0-4]|1?[0-9])?[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1?[0-9])?[0-9])\.){3}(25[0-5]|(2[0-4]|1?[0-9])?[0-9]))$ISO Date Format (YYYY-MM-DD)
Validate ISO 8601 date format
Tags
regex, regular-expression, pattern, validation, date, iso, format, basic
^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$24-Hour Time Format
Validate time in HH:MM format
Tags
regex, regular-expression, pattern, validation, time, 24h, format, basic
^([01]\d|2[0-3]):[0-5]\d$US Phone Number
Match US phone number formats
Tags
regex, regular-expression, pattern, validation, phone, us, contact
^(\+?1[-.\s]?)?\(?[0-9]{3}\)?[-.\s]?[0-9]{3}[-.\s]?[0-9]{4}$Username
Validate username (alphanumeric, underscore, hyphen)
Tags
regex, regular-expression, pattern, validation, username, user, account, basic
^[a-zA-Z0-9_-]{3,16}$Strong Password
Validate strong password (min 8 chars, uppercase, lowercase, number, special)
Tags
regex, regular-expression, pattern, validation, password, security
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$US Postal Code (ZIP)
Validate US ZIP code format
Tags
regex, regular-expression, pattern, validation, postal, zip, us, basic
^\d{5}(-\d{4})?$Credit Card Number
Match major credit card numbers
Tags
regex, regular-expression, pattern, validation, credit-card, payment, financial, advanced
^(?:4[0-9]{12}(?:[0-9]{3})?|(?:5[1-5][0-9]{14}|2(?:2[2-9][0-9]{2}|[3-6][0-9]{3}|7(?:[01][0-9]{2}|20[0-9]))[0-9]{12})|6(?:011|5[0-9]{2})[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$Hexadecimal Color Code
Match hex color codes (#RGB or #RRGGBB)
Tags
regex, regular-expression, pattern, validation, color, hex, css, basic
^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$US Social Security Number
Validate SSN format
Tags
regex, regular-expression, pattern, validation, ssn, us, identification
^(?!000|666)[0-8]\d{2}-(?!00)\d{2}-(?!0000)\d{4}$HTML Tag
Match HTML tags
Tags
regex, regular-expression, pattern, validation, html, tag, web
^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$Integer Number
Match positive/negative integers
Tags
regex, regular-expression, pattern, validation, number, integer, basic
^-?\d+$Decimal Number
Match decimal numbers with optional sign
Tags
regex, regular-expression, pattern, validation, number, decimal, basic
^-?\d+(?:\.\d+)?$UUID / GUID
Validate UUID format
Tags
regex, regular-expression, pattern, validation, uuid, guid, identifier
^[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}$MAC Address
Validate MAC address format
Tags
regex, regular-expression, pattern, validation, mac, network, hardware
^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$Tools
Tools frequently paired with this sample
Related
Related sample collections
Related