Regex Library
Browse common regex patterns organized by category
Test your patterns in our Regex Tester
Simple Email
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$Matches a basic email address format
Email with Display Name
^[^<]*<[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}>$Matches an email with a display name like "John Doe <john@example.com>"
Email Domain Extraction
@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})Extracts the domain part from an email address
No-Reply Email
^no-?reply@Matches email addresses starting with no-reply or noreply
URL
URL with Protocol
^https?:\/\/[^\s/$.?#].[^\s]*$Matches a URL starting with http:// or https://
URL Slug
^[a-z0-9]+(?:-[a-z0-9]+)*$Matches a URL-safe slug with lowercase letters, numbers, and hyphens
Domain Name
^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$Matches a valid domain name like example.com or sub.domain.org
URL Query Parameter
[?&]([^=]+)=([^&]*)Extracts key=value pairs from URL query strings
YouTube Video ID
(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]{11})Extracts the 11-character video ID from YouTube URLs
Date & Time
ISO 8601 Date
^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$Matches dates in ISO 8601 format (YYYY-MM-DD)
Date (MM/DD/YYYY)
^(0[1-9]|1[0-2])\/(0[1-9]|[12]\d|3[01])\/\d{4}$Matches dates in US format (MM/DD/YYYY)
Date (DD/MM/YYYY)
^(0[1-9]|[12]\d|3[01])\/(0[1-9]|1[0-2])\/\d{4}$Matches dates in European format (DD/MM/YYYY)
24-Hour Time
^([01]\d|2[0-3]):([0-5]\d)(?::([0-5]\d))?$Matches time in 24-hour format with optional seconds
12-Hour Time
^(0?[1-9]|1[0-2]):[0-5]\d\s?(?:AM|PM|am|pm)$Matches time in 12-hour format with AM/PM
Number
Integer
^-?\d+$Matches positive or negative whole numbers
Decimal Number
^-?\d+\.?\d*$Matches positive or negative numbers with optional decimal part
Hex Color
^#(?:[0-9a-fA-F]{3}){1,2}$Matches 3 or 6 digit hex color codes with # prefix
Currency (USD)
^\$\d{1,3}(,\d{3})*(\.\d{2})?$Matches US dollar amounts with optional cents and thousands separators
Percentage
^-?\d+(\.\d+)?%$Matches percentage values with optional decimal part
Phone
International Phone
^\+?[1-9]\d{1,14}$Matches international phone numbers in E.164 format
US Phone
^(\+1)?[-.\s]?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$Matches US phone numbers in various formats
Phone with Extension
^(\+?\d{1,3})?[-.\s]?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}(\s*(ext|x|ext.)\s*\d{2,5})?$Matches phone numbers with optional country code and extension
Digits Only (Phone)
^\d{10,15}$Matches phone numbers as digit-only strings (10 to 15 digits)
IP & Network
IPv4 Address
^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$Matches a valid IPv4 address (0.0.0.0 to 255.255.255.255)
IPv4 with Port
^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?):(\d{1,5})$Matches an IPv4 address followed by a port number
IPv6 Address
^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$Matches a full IPv6 address (8 groups of hex digits)
MAC Address
^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$Matches a MAC address with colon or dash separators
CIDR Notation
^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\/(?:3[0-2]|[12]?\d)$Matches an IPv4 address with CIDR subnet notation
File & Path
File Extension
\.([a-zA-Z0-9]+)$Extracts the file extension from a filename
Unix File Path
^\/(?:[^\/ ]+\/)*[^\/ ]+$Matches an absolute Unix/Linux file path
Windows File Path
^[a-zA-Z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*$Matches an absolute Windows file path
Image File
\.(jpe?g|png|gif|bmp|svg|webp|ico|tiff?)$Matches filenames with common image extensions
Password
Min 8 Characters
^.{8,}$Matches any string with at least 8 characters
Strong Password
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$Requires uppercase, lowercase, digit, and special character (min 8 chars)
No Spaces
^\S+$Matches strings that contain no whitespace characters
Alphanumeric Only
^[a-zA-Z0-9]+$Matches strings containing only letters and digits
HTML & XML
HTML Tag
<\/?[a-zA-Z][a-zA-Z0-9]*[^>]*>Matches opening and closing HTML tags
HTML Comment
<!--[\s\S]*?-->Matches HTML comments including multiline content
HTML Attribute
([a-zA-Z-]+)\s*=\s*"([^"]*)"Extracts attribute name and value pairs from HTML elements
Self-Closing Tag
<[a-zA-Z][a-zA-Z0-9]*[^>]*\/>Matches self-closing HTML/XML tags like <br /> or <img />
Miscellaneous
UUID v4
^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$Matches a UUID version 4 string (lowercase hex)
JWT Token
^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+$Matches the three-part structure of a JSON Web Token
Markdown Link
\[([^\]]+)\]\(([^)]+)\)Matches Markdown-style links [text](url)
Semantic Version
^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*))?$Matches semantic version strings like 1.2.3 or v2.0.0-beta.1
Base64 String
^[A-Za-z0-9+/]*={0,2}$Matches valid Base64-encoded strings
Más información
Browse a curated collection of regex patterns for email, URL, date, and more.
¿Qué es una biblioteca de regex?
Una biblioteca de regex es una colección curada de patrones de expresiones regulares para tareas comunes de validación y extracción. En lugar de escribir regex desde cero cada vez, puedes explorar patrones probados para emails, URLs, fechas, direcciones IP y docenas de otros formatos.