Regex Cheat Sheet
Quick reference for regular expression syntax with search and filter.
Characters
.Any character except newline
a.c matches abc, aXc
\dDigit (0-9)
\d+ matches 123
\DNon-digit
\D+ matches abc
\wWord character (a-z, A-Z, 0-9, _)
\w+ matches hello_1
\WNon-word character
\W matches @, !
\sWhitespace (space, tab, newline)
a\sb matches a b
\SNon-whitespace
\S+ matches hello
[abc]Character set — matches a, b, or c
[aeiou] matches vowels
[^abc]Negated set — anything except a, b, c
[^0-9] matches non-digits
[a-z]Character range
[A-Za-z] matches letters
Quantifiers
*0 or more
ab*c matches ac, abc, abbc
+1 or more
ab+c matches abc, abbc
?0 or 1 (optional)
colou?r matches color, colour
{n}Exactly n times
a{3} matches aaa
{n,}n or more times
a{2,} matches aa, aaa
{n,m}Between n and m times
a{2,4} matches aa, aaa, aaaa
*?0 or more (lazy)
a.*?b matches ab in aXbYb
+?1 or more (lazy)
a.+?b matches aXb in aXbYb
Groups
(abc)Capturing group
(ha)+ matches haha
(?:abc)Non-capturing group
(?:ha)+ matches haha
(?<name>abc)Named capturing group
(?<year>\d{4})
\1Back-reference to group 1
(\w)\1 matches aa, bb
(a|b)Alternation — a or b
(cat|dog) matches cat or dog
Anchors
^Start of string / line
^Hello matches Hello at start
$End of string / line
world$ matches world at end
\bWord boundary
\bcat\b matches cat, not catch
\BNon-word boundary
\Bcat matches catch, not cat
Flags
gGlobal — all matches
/a/g finds all a's
iCase-insensitive
/hello/i matches Hello
mMultiline — ^ and $ match per line
/^a/m matches a on each line
sDotall — . matches newline
/a.b/s matches a\nb
uUnicode support
/\u{1F600}/u matches emoji
Lookahead / Lookbehind
(?=abc)Positive lookahead
a(?=b) matches a in ab
(?!abc)Negative lookahead
a(?!b) matches a in ac
(?<=abc)Positive lookbehind
(?<=a)b matches b in ab
(?<!abc)Negative lookbehind
(?<!a)b matches b in cb
How to Use Regex Cheat Sheet
Step 1
Browse categories like Characters, Quantifiers, Groups, and more.
Step 2
Use the search bar to filter patterns by keyword.
Step 3
Review the syntax, description, and example for each pattern.
Step 4
Use patterns directly in your code or regex tester.
Features
Comprehensive coverage of common regex patterns.
Organized into logical categories for easy browsing.
Instant search and filter across all patterns.
Each entry includes syntax, description, and example.
FAQ
A regular expression (regex) is a sequence of characters that defines a search pattern, commonly used for string matching, validation, and text manipulation.
This cheat sheet covers standard regex syntax supported by most languages including JavaScript, Python, Java, and others. Language-specific extensions are noted where applicable.
Yes. Use the search bar at the top to filter patterns by syntax, description, or example text.
The cheat sheet is a static reference with a search filter. For live regex testing, check out our Regex Tester tool.