Common Regex Patterns — Email, URL, Phone, IP & More

Ready-to-use regex patterns for validation: email, URL, phone number, IP address, dates, passwords, credit cards.

Email Validation

# Simple
^[\w.-]+@[\w.-]+\.\w{2,}$

# RFC 5322 (more thorough)
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$

URL Validation

# HTTP/HTTPS URL
^https?:\/\/[\w.-]+(?:\.[\w.-]+)+[\w.,@?^=%&:/~+#-]*$

# With optional path and query
^https?:\/\/(?:www\.)?[\w-]+(?:\.[\w-]+)+(?:\/[\w._~:/?#@!$&'()*+,;=-]*)?$

Phone Numbers

# US format
^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$

# International (E.164)
^\+[1-9]\d{1,14}$

IP Addresses

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

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

Dates

# YYYY-MM-DD
^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$

# MM/DD/YYYY
^(?:0[1-9]|1[0-2])\/(?:0[1-9]|[12]\d|3[01])\/\d{4}$

Passwords

# Min 8 chars, 1 uppercase, 1 lowercase, 1 digit
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$

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

Other Useful Patterns

PatternRegex
Hex color^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$
Slug^[a-z0-9]+(?:-[a-z0-9]+)*$
UUID v4^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
Semantic version^\d+\.\d+\.\d+(?:-[\w.]+)?$
HTML tag<([a-z]+)(?:\s[^>]*)?>.*?<\/\1>

Need These Tools as an API?

TextForge API offers 20+ developer toolkit endpoints. Free tier: 50 requests/day.

Try TextForge API Free →

Related Tools