Regex Library

Find and copy regex patterns for common use cases.

Test Your Regex

Try patterns with our interactive regex tester

23 patterns

Email Address

i

Email & Contact

Validates standard email addresses

^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
user@example.com
john.doe@company.co.uk

US Phone Number

Email & Contact

Matches US phone numbers in various formats

^(\+1)?[\s.-]?\(?([0-9]{3})\)?[\s.-]?([0-9]{3})[\s.-]?([0-9]{4})$
(555) 123-4567
+1-555-123-4567

International Phone

Email & Contact

E.164 format international phone numbers

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

URL (HTTP/HTTPS)

URLs & Web

Validates 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.com
http://www.site.com/path

Domain Name

i

URLs & Web

Validates domain names

^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$
example.com
sub.domain.co.uk

IPv4 Address

URLs & Web

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]?)$
192.168.1.1
10.0.0.255

URL Slug

URLs & Web

Validates URL-friendly slugs

^[a-z0-9]+(?:-[a-z0-9]+)*$
my-blog-post
product-name-123

Strong Password

Passwords & Security

At least 8 chars, 1 uppercase, 1 lowercase, 1 number, 1 special char

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

JWT Token

Passwords & Security

Matches JSON Web Tokens

^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$
eyJhbGc.eyJzdWI.SflKxw

Integer

Numbers & Currency

Matches positive or negative integers

^-?\d+$
123
-456
0

Decimal Number

Numbers & Currency

Matches integers and decimal numbers

^-?\d+(\.\d+)?$
123.45
-67.89

US Dollar Amount

Numbers & Currency

Matches US dollar amounts

^\$?\d{1,3}(,\d{3})*(\.\d{2})?$
$1,234.56
999.99

Credit Card Number

Numbers & Currency

Validates major credit card formats

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

ISO Date (YYYY-MM-DD)

Dates & Time

Matches ISO 8601 date format

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

24-Hour Time

Dates & Time

Matches 24-hour time format

^([01]\d|2[0-3]):([0-5]\d)$
14:30
23:59

Filename

File & Path

Matches filenames with extensions

^[\w,\s-]+\.[A-Za-z]{2,4}$
document.pdf
image.jpg

Image File

i

File & Path

Matches common image file extensions

^.+\.(jpg|jpeg|png|gif|bmp|svg|webp)$
photo.jpg
icon.png

Hex Color

HTML & Code

Matches hex color codes

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

Variable Name

HTML & Code

Matches valid JavaScript variable names

^[a-zA-Z_$][a-zA-Z0-9_$]*$
myVariable
_private

Username

Text & Content

Alphanumeric username, 3-16 characters

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

Hashtag

Text & Content

Matches social media hashtags

^#[a-zA-Z0-9_]+$
#coding
#WebDev

UUID

i

Text & Content

Matches UUID v4 format

^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
550e8400-e29b-41d4-a716-446655440000

US ZIP Code

Geographic

Matches US ZIP codes

^\d{5}(-\d{4})?$
12345
12345-6789

About Regex Library

Regular expressions (regex) are powerful patterns used for matching, searching, and manipulating text. This library provides ready-to-use regex patterns for common validation and extraction tasks.

How to Use

  • Browse patterns by category or search by name
  • Click copy button to copy pattern to clipboard
  • Test patterns using our Regex Tester tool
  • Flags like 'i' indicate case-insensitive matching