Top 50 Regex Patterns Developers Actually Use

Copy-paste ready regular expressions for validation, parsing, and text manipulation. Tested and battle-proven patterns for everyday development.

No data uploaded – runs 100% in your browser
Used by developers in 120+ countries
v2025.1 • Updated Nov 2025
Leaderboard Ad

Email Address

Validates email format

#1
^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,}$

URL

Matches HTTP/HTTPS URLs

#2
^(https?:\/\/)?([\w.-]+)\.([a-z]{2,})(\/\S*)?$

Phone (US)

US phone number formats

#3
^\+?1?[-.\s]?$$?\d{3}$$?[-.\s]?\d{3}[-.\s]?\d{4}$

Phone (International)

E.164 international format

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

Date (YYYY-MM-DD)

ISO date format

#5
^\d{4}-\d{2}-\d{2}$

Date (MM/DD/YYYY)

US date format

#6
^\d{2}\/\d{2}\/\d{4}$

Time (24hr)

24-hour time format

#7
^([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$

IPv4 Address

Valid IPv4 address

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

IPv6 Address

Full IPv6 address

#9
^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$

Hex Color

CSS hex color code

#10
^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$

Username

Alphanumeric, 3-16 chars

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

Password (Strong)

Min 8 chars, upper, lower, number, special

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

Credit Card

16-digit card number

#13
^\d{4}[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}$

SSN

US Social Security Number

#14
^\d{3}-\d{2}-\d{4}$

ZIP Code (US)

5 or 9 digit ZIP

#15
^\d{5}(-\d{4})?$

Postal Code (UK)

UK postcode format

#16
^[A-Z]{1,2}\d[A-Z\d]? ?\d[A-Z]{2}$

UUID

Standard UUID format

#17
^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$

Slug

URL-friendly slug

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

HTML Tag

Matches HTML tags

#19
<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)

Whitespace

Only whitespace

#20
^\s*$

Non-Empty

At least one non-whitespace

#21
\S+

Digits Only

Only numbers

#22
^\d+$

Letters Only

Only letters

#23
^[a-zA-Z]+$

Alphanumeric

Letters and numbers only

#24
^[a-zA-Z0-9]+$

No Special Chars

Letters, numbers, spaces

#25
^[a-zA-Z0-9 ]+$

Currency (USD)

US dollar format

#26
^\$?\d{1,3}(,\d{3})*(\.\d{2})?$

Percentage

Number with percent sign

#27
^\d+(\.\d+)?%$

File Extension

Extract file extension

#28
\.([a-zA-Z0-9]+)$

Image File

Common image extensions

#29
\.(jpg|jpeg|png|gif|webp|svg)$

Domain Name

Valid domain name

#30
^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$

MAC Address

Network MAC address

#31
^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$

Latitude

Valid latitude

#32
^-?([1-8]?\d(\.\d+)?|90(\.0+)?)$

Longitude

Valid longitude

#33
^-?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$

Markdown Link

Extract markdown links

#34
\[([^\]]+)\]$$([^)]+)$$

YouTube URL

Extract YouTube video ID

#35
(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)

Twitter Handle

Twitter/X username

#36
^@?[a-zA-Z0-9_]{1,15}$

Hashtag

Social media hashtag

#37
#[a-zA-Z0-9_]+

JSON String

Valid JSON string

#38
"([^"\\]|\\.)*"

Word Boundary

Match whole words

#39
\b\w+\b

Duplicate Words

Find repeated words

#40
\b(\w+)\s+\1\b

Leading/Trailing Space

Trim whitespace

#41
^\s+|\s+$

Multiple Spaces

Two or more spaces

#42
\s{2,}

Empty Lines

Blank lines

#43
^\s*$\n

Sentence

Match sentences

#44
[A-Z][^.!?]*[.!?]

Camel Case

camelCase format

#45
^[a-z]+([A-Z][a-z]+)*$

Pascal Case

PascalCase format

#46
^([A-Z][a-z]+)+$

Snake Case

snake_case format

#47
^[a-z]+(_[a-z]+)*$

Kebab Case

kebab-case format

#48
^[a-z]+(-[a-z]+)*$

Base64

Base64 encoded string

#49
^[A-Za-z0-9+/]+=*$

JWT Token

JSON Web Token format

#50
^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$
Multiplex Ad

Related Resources