tool / 45

Regex Patterns

Battle-tested regex you can copy and paste. Validation patterns and extraction patterns.

All local
22/22
Validation12
Email
/^[\w.+-]+@[\w-]+\.[\w.-]+$/
e.g. ada@example.com
URL (http/s)
/^https?:\/\/[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=]*$/
e.g. https://example.com/path
IPv4
/^(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)$/
e.g. 192.168.1.1
IPv6 (loose)
/^[0-9a-fA-F:]+$/
e.g. 2001:db8::1
MAC address
/^([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}$/
e.g. 01:23:45:67:89:ab
UUID v4
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/
e.g. 550e8400-e29b-41d4-a716-446655440000
Hex color
/^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/
e.g. #ff5d3b
Slug
/^[a-z0-9]+(?:-[a-z0-9]+)*$/
e.g. hello-world
ISO date
/^\d{4}-\d{2}-\d{2}$/
e.g. 2026-04-08
Time HH:MM
/^([01]\d|2[0-3]):[0-5]\d$/
e.g. 14:30
Phone (intl loose)
/^\+?[1-9]\d{1,14}$/
e.g. +447700900000
Strong password
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w\s]).{8,}$/
e.g. Hunter2!
Extraction10
Whitespace
/\s+/
e.g. split lines
Word
/\b\w+\b/
e.g. hello world
Hashtag
/#[\w\d_]+/
e.g. #devbox
Mention
/@[\w\d_]+/
e.g. @ada
Markdown link
/\[([^\]]+)\]\(([^)]+)\)/
e.g. [text](url)
Markdown image
/!\[([^\]]*)\]\(([^)]+)\)/
e.g. ![alt](url)
Hex number
/0x[0-9a-fA-F]+/
e.g. 0xCAFE
JSON string
/"(?:[^"\\]|\\.)*"/
e.g. "hello"
HTML tag
/<\/?[a-zA-Z][^>]*>/
e.g. <p>
Credit card (loose)
/\b(?:\d[ -]*?){13,16}\b/
e.g. 4111 1111 1111 1111