Regex Cheat Sheet & Live Tester
Complete regular expression reference with real-time pattern testing
0 patterns tested
Live Tester
Cheat Sheet
Email
URL
IP Address
Phone
Hex Color
Date
Hello
Names
Decimals
Email (case-insensitive)
g global
i insensitive
m multiline
s dotall
u unicode
/
/
Character Classes
.Any character except newline
\dAny digit [0-9]
\DAny non-digit [^0-9]
\wWord character [a-zA-Z0-9_]
\WNon-word character [^a-zA-Z0-9_]
\sWhitespace (space, tab, newline)
\SNon-whitespace character
[abc]Match a, b, or c
[^abc]Not a, b, or c
[a-z]Character range a through z
[A-Z]Uppercase letter range
[0-9]Digit range (same as \d)
Anchors
^Start of string (or line with m flag)
$End of string (or line with m flag)
\bWord boundary
\BNon-word boundary
Quantifiers
*0 or more (greedy)
+1 or more (greedy)
?0 or 1 (optional)
{n}Exactly n times
{n,}n or more times
{n,m}Between n and m times
*?0 or more (lazy / non-greedy)
+?1 or more (lazy / non-greedy)
Groups & Alternation
(abc)Capturing group
(?:abc)Non-capturing group
(?<name>abc)Named capturing group
\1Backreference to group 1
a|bAlternation (a or b)
Lookaheads & Lookbehinds
(?=abc)Positive lookahead: followed by abc
(?!abc)Negative lookahead: NOT followed by abc
(?<=abc)Positive lookbehind: preceded by abc
(?<!abc)Negative lookbehind: NOT preceded by abc
Flags / Modifiers
gGlobal: find all matches, not just the first
iCase-insensitive matching
mMultiline: ^ and $ match line boundaries
sDotall: . matches newlines too
uUnicode: treat pattern as Unicode code points
ySticky: match from lastIndex only
Special Characters & Escapes
\Escape the next character
\nNewline
\tTab character
\rCarriage return
\0Null character
\xHHHex character (e.g. \x41 = A)
\uHHHHUnicode character (e.g. \u00E9 = e with accent)
Common Patterns
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}Email address
https?://[^\s]+URL (http or https)
\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}US phone number
\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\bIPv4 address
#([0-9a-fA-F]{3}){1,2}\bHex color code
\b\d{4}-\d{2}-\d{2}\bDate (YYYY-MM-DD)
\d{2}/\d{2}/\d{4}Date (MM/DD/YYYY)
\d{1,2}:\d{2}(:\d{2})?\s?(AM|PM|am|pm)?Time (12h or 24h)
\d{5}(-\d{4})?US ZIP code (5 or 9 digit)
\d{3}-\d{2}-\d{4}SSN format (XXX-XX-XXXX)
(?:25[0-5]|2[0-4]\d|[01]?\d\d?)(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d\d?)){3}Validated IPv4 (0-255 per octet)
<[^>]+>HTML tags
')">Try^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).{8,}$Strong password (8+ chars, upper, lower, digit, special)
^[a-zA-Z0-9_-]{3,16}$Username (3-16 chars, alphanum, dash, underscore)
[-+]?\d*\.?\d+([eE][-+]?\d+)?Number (integer, decimal, scientific)
\$[\d,]+\.?\d*Currency ($1,234.56)
(?:(?:https?|ftp):\/\/)?[\w/\-?=%.]+\.[\w/\-&?=%.]+URL (flexible, with or without protocol)
[A-Z]{1,2}\d[A-Z\d]?\s?\d[A-Z]{2}UK postcode
\/\*[\s\S]*?\*\/|\/\/.*JavaScript comments (single + multi-line)
[\"']([^\"']*)[\"']Quoted strings (single or double)
POSIX-Style & Unicode (not all JS-supported)
\p{L}Any Unicode letter (requires u flag)
\p{N}Any Unicode number (requires u flag)
\p{Emoji}Emoji characters (requires u flag)
\p{Script=Latin}Latin script characters (requires u flag)
More Free Tools
Regex Tester
Password Generator
JSON Formatter
Lorem Ipsum
Base64 Tool
URL Encoder
Cron Generator
Markdown Editor
Color Palette
Get All 40+ Tools
Lifetime Pass ($99.99) gets every tool we build. Or resell them all under your brand from $99.
Visit the Store