SyntaxStudy
Sign Up
JavaScript Intermediate 4 min read

Common Regex Patterns

Common Regex Patterns

A reference collection of frequently used regex patterns for validation and parsing tasks.

Example
// Email (simple, practical)
/^[^\s@]+@[^\s@]+\.[^\s@]+$/

// URL
/^https?:\/\/[\w\-]+(\.[\w\-]+)+([\w\-._~:/?#[\]@!$&'()*+,;=]*)?$/

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

// Strong password (8+ chars, upper, lower, digit, special)
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&]).{8,}$/

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

// IPv4
/^(\d{1,3}\.){3}\d{1,3}$/
Pro Tip

Never use regex alone for email validation — send a confirmation email to verify the address actually exists.