Regex Library

Browse common regular expression patterns — copy and test instantly

Email Address

email
^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$

Matches a standard email address with local part, @ symbol, domain, and TLD.

URL (http/https)

url
^https?://[a-zA-Z0-9][a-zA-Z0-9.\-]*\.[a-zA-Z]{2,}(/[^\s]*)?$ /i

Matches HTTP and HTTPS URLs with a valid hostname.

https://example.comhttp://www.example.org/path?q=1https://sub.domain.co.uk/page

Phone E.164

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

Matches international phone numbers in E.164 format (e.g. +14155552671).

+14155552671+447911123456+33123456789

Date YYYY-MM-DD

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

Matches dates in ISO 8601 date format YYYY-MM-DD.

2024-01-152000-12-311999-06-01

ISO Datetime

date
^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$

Matches ISO 8601 datetime strings with optional fractional seconds and timezone.

2024-01-15T10:30:00Z2024-06-01T23:59:59.999Z2024-03-10T08:00:00+05:30

Integer

number
^-?\d+$

Matches positive or negative integers.

042-100999999

Decimal Number

number
^-?\d+(\.\d+)?$

Matches positive or negative decimal numbers.

3.14-2.50.001100

UUID v4

id
^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$ /i

Matches a UUID version 4 string (random, RFC 4122).

550e8400-e29b-41d4-a716-446655440000f47ac10b-58cc-4372-a567-0e02b2c3d4796ba7b810-9dad-41d1-80b4-00c04fd430c8

Hex Colour

misc
^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$

Matches CSS hex colour values in 3 or 6 digit form.

#fff#FFF#1a2b3c#FF5733

IPv4 Address

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

Matches a valid IPv4 address with values 0-255 in each octet.

192.168.1.110.0.0.2550.0.0.0255.255.255.255

Slug

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

Matches a URL slug: lowercase letters, digits, and hyphens (no leading/trailing hyphens).

hello-worldmy-page-123sluga1b2c3

Semantic Version

misc
^(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-]+)*))?$

Matches a Semantic Versioning (semver) string.

1.0.02.3.41.0.0-alpha.10.1.0+build.123