Regex Pattern Collection

Find, test, and create common regex patterns with ease

Email Address

Contact

Matches valid email addresses

^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$

Examples:

  • user@example.com
  • name.surname@domain.co.uk

Phone Number

Contact

Matches international phone numbers (E.164 format)

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

Examples:

  • +1234567890
  • 123456789

URL

Web

Matches valid URLs

https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)

Examples:

  • https://www.example.com
  • http://subdomain.domain.co.uk/path

Strong Password

Security

Minimum 8 characters, at least one letter, one number and one special character

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

Examples:

  • Password123!
  • Secure@99

IPv4 Address

Network

Matches valid IPv4 addresses

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

Examples:

  • 192.168.1.1
  • 10.0.0.0

Date (YYYY-MM-DD)

Date & Time

Matches dates in YYYY-MM-DD format

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

Examples:

  • 2024-03-15
  • 1999-12-31

Credit Card Number

Finance

Matches major credit card numbers (Visa, MasterCard, American Express, Discover)

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

Examples:

  • 4111111111111111
  • 5500000000000004

Hex Color

Web

Matches hexadecimal color codes

^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$

Examples:

  • #FF0000
  • #f00

Username

Security

Alphanumeric string that may include _ and - having a length of 3 to 16 characters

^[a-zA-Z0-9_-]{3,16}$

Examples:

  • user_123
  • john-doe

Postal Code (US)

Address

Matches US postal codes with optional 4 digit extension

^\d{5}(?:[-\s]\d{4})?$

Examples:

  • 12345
  • 12345-6789

Test Pattern

Try out the selected regex pattern with your own input

Email Address

Contact

Matches valid email addresses

^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$

Match: No