> codebench_TOOL: HomeLOCAL-ONLY⌘K Switch
Search:

Character Classes

PatternDescriptionExample
.Any character except newlinea.c → abc, a1c
\dDigit [0-9]\d+ → 123
\DNon-digit [^0-9]—
\wWord character [a-zA-Z0-9_]\w+ → hello_1
\WNon-word character [^\w]—
\sWhitespace [ \t\n\r\f\v]—
\SNon-whitespace—
[abc]Any of a, b, or c[aeiou] → vowels
[^abc]Not a, b, or c—
[a-z]Character range a to z—
[a-zA-Z]Any letter—
[0-9]Any digit (same as \d)—

Quantifiers

PatternDescriptionExample
*0 or more (greedy)a* → "", a, aaa
+1 or more (greedy)a+ → a, aaa
?0 or 1 (optional)colou?r → color, colour
{n}Exactly n times\d{3} → 123
{n,}n or more times\d{2,} → 12, 123
{n,m}Between n and m times\d{2,4} → 12, 1234
*?0 or more (lazy)—
+?1 or more (lazy)—
??0 or 1 (lazy)—

Anchors

PatternDescriptionExample
^Start of string/line^Hello → Hello world
$End of string/lineworld$ → Hello world
\bWord boundary\bcat\b → cat (not cats)
\BNon-word boundary—

Groups & Backreferences

PatternDescriptionExample
(abc)Capturing group(\d+)-(\d+) → groups
(?:abc)Non-capturing group—
(?<name>abc)Named capturing group(?<year>\d{4})
\1Backreference to group 1(\w)\1 → aa, bb
(a|b)Alternation (a or b)cat|dog → cat, dog

Lookahead & Lookbehind

PatternDescriptionExample
(?=abc)Positive lookahead\d(?=px) → 5 in 5px
(?!abc)Negative lookahead\d(?!px) → 5 in 5em
(?<=abc)Positive lookbehind(?<=\$)\d+ → 100 in $100
(?<!abc)Negative lookbehind—

Flags

PatternDescriptionExample
gGlobal — find all matches—
iCase-insensitive matching—
mMultiline — ^ and $ match line boundaries—
sDotall — . matches newlines—
uUnicode support—
ySticky — match from lastIndex only—

Special Characters

PatternDescriptionExample
\nNewline—
\tTab—
\rCarriage return—
\0Null character—
\\Literal backslash—
\.Escaped dot (literal .)—

Common Patterns

NamePatternDescription
Email[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}Basic email address
URLhttps?:\/\/[\w\-._~:/?#\[\]@!$&'()*+,;=%]+HTTP/HTTPS URL
IPv4\b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\bIPv4 address
IPv6(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}IPv6 address (full form)
Phone (US)\+?1?[\s.-]?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}US phone number
Phone (KR)0\d{1,2}[\s.-]?\d{3,4}[\s.-]?\d{4}Korean phone number
Date (YYYY-MM-DD)\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])ISO date format
Time (HH:MM:SS)(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?24-hour time
Hex Color#(?:[0-9a-fA-F]{3}){1,2}\bCSS hex color
UUID[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}UUID v1-v5
HTML Tag<\/?[a-zA-Z][a-zA-Z0-9]*(?:\s[^>]*)?\/?>HTML tags
Korean[가-힣]+Korean characters (Hangul)
Japanese[\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF]+Japanese (Hiragana/Katakana/Kanji)
Chinese[\u4E00-\u9FFF]+Chinese characters (CJK Unified)
Whitespace Trim^\s+|\s+$Leading/trailing whitespace
Duplicate Lines^(.*)\n(?=.*\1)Repeated lines
> codebench $Ctrl+Enter Run

What is Regex Cheatsheet?

Comprehensive regex syntax reference organized by category — character classes, quantifiers, anchors, groups, backreferences, and lookahead/lookbehind. Includes a library of common patterns (email, URL, IP, phone, date, etc.) with one-click copy and direct link to Regex Tester.

Key Features