Developer · DEV-20Submit an issue

Common regex reference

Search regular expressions for common formats such as email, URL, IPv4, dates, UUIDs, colors and ports.

Search by format · Copy regex
Search patterns

These patterns check common text formats only; they do not prove that an address, account or business value is real or valid.

NameRegular expressionDescription
Email format^[^\s@]+@[^\s@]+\.[^\s@]+$Basic email text format; not mailbox verification
HTTP(S) URL^https?:\/\/[^\s/$.?#].[^\s]*$Requires an http:// or https:// prefix
IPv4 address^(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)$Four decimal octets from 0 to 255
ISO date^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$YYYY-MM-DD shape with basic month and day ranges
24-hour time^(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?$HH:mm or HH:mm:ss from 00:00 to 23:59:59
Integer^[+-]?\d+$Optional sign followed by digits
Decimal number^[+-]?(?:\d+\.?\d*|\.\d+)$Common decimal notation without exponent
Hexadecimal value^(?:0x)?[0-9a-fA-F]+$Optional 0x prefix and hexadecimal digits
UUID^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$Canonical hyphenated UUID versions 1 through 8
HEX color^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$3, 6 or 8 hexadecimal color digits
Hostname^(?=.{1,253}$)(?:[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])?$DNS-style labels; no reachability check
TCP/UDP port^(?:0|[1-9]\d{0,3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$Decimal port number from 0 to 65535
Username format^[a-zA-Z][a-zA-Z0-9_-]{2,31}$3 to 32 characters, beginning with a letter
Semantic version^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$Core SemVer with optional prerelease and build text
Blank line^\s*$A line containing whitespace only
Usage guide and examples

Common regex reference

Search regular expressions for common formats such as email, URL, IPv4, dates, UUIDs, colors and ports.

Check the input format and options with this example before using your own data. Random values, file sizes and presentation vary with the input and settings.

Example input and settings

IPv4

What to check in the result

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