Regex Cheat Sheet

A searchable reference of common regular expression syntax — character classes, anchors, quantifiers, groups, lookaround, and flags — with examples.

CategoryPatternDescriptionExample
Character classes
.Any character except newlinea.c matches abc
Character classes
\dDigit (0-9)\d+ matches 123
Character classes
\DNon-digit\D+ matches abc
Character classes
\wWord character (letters, digits, underscore)\w+ matches hello_1
Character classes
\WNon-word character\W matches @
Character classes
\sWhitespace\s+ matches spaces/tabs
Character classes
\SNon-whitespace\S+ matches non-space run
Character classes
[abc]Any of a, b, or c[abc] matches a, b, or c
Character classes
[^abc]Anything except a, b, or c[^abc] matches d, e, ...
Character classes
[a-z]Any lowercase letter (range)[a-z]+ matches hello
Anchors
^Start of string (or line with m flag)^abc matches abc at start
Anchors
$End of string (or line with m flag)abc$ matches abc at end
Anchors
\bWord boundary\bcat\b matches whole word cat
Anchors
\BNon-word boundary\Bcat matches concatenate
Quantifiers
*0 or moreab*c matches ac, abc, abbc
Quantifiers
+1 or moreab+c matches abc, abbc
Quantifiers
?0 or 1 (optional)ab?c matches ac or abc
Quantifiers
{n}Exactly n timesa{3} matches aaa
Quantifiers
{n,}n or more timesa{2,} matches aa, aaa, ...
Quantifiers
{n,m}Between n and m timesa{2,4} matches aa to aaaa
Quantifiers
*?0 or more, lazy (non-greedy)<.+?> matches shortest tag
Groups
(abc)Capturing group(ab)+ captures repeated ab
Groups
(?:abc)Non-capturing group(?:ab)+ groups without capturing
Groups
(?<name>abc)Named capturing group(?<year>\d{4})
Groups
a|bAlternation (OR)cat|dog matches cat or dog
Lookaround
(?=abc)Positive lookahead\d+(?=px) matches digits before px
Lookaround
(?!abc)Negative lookahead\d+(?!px) digits not before px
Lookaround
(?<=abc)Positive lookbehind(?<=\$)\d+ digits after $
Lookaround
(?<!abc)Negative lookbehind(?<!\$)\d+ digits not after $
Flags
gGlobal — find all matches/abc/g
Flags
iCase-insensitive/abc/i matches ABC
Flags
mMultiline — ^ and $ match line boundaries/^abc/m
Flags
sDot matches newline too/a.b/s
Flags
uUnicode mode/\u{1F600}/u

Regex Cheat Sheet — Free Online Tool

A searchable reference of common regular expression syntax — character classes, anchors, quantifiers, groups, lookaround, and flags — with examples.

How to use the Regex Cheat Sheet

  • Open the tool above — it runs entirely in your browser, so your input never leaves this page.
  • Paste or type your input into the field, then press the relevant button (e.g. Encode / Decode, Generate, or Convert).
  • Copy the result from the output area with the copy button orCtrl/Cmd + C.
  • No signup, no upload, and no tracking — repeat as often as you need.

Frequently asked questions

Is the Regex Cheat Sheet free to use?

Yes. The Regex Cheat Sheet is completely free, with no signup, no ads inside the tool, and no hidden limits.

Does the Regex Cheat Sheet upload my data?

No. The Regex Cheat Sheet processes everything locally in your browser. Your input is never sent to a server, so it stays private even on shared devices.

Does the Regex Cheat Sheet work offline?

After the page loads, the Regex Cheat Sheet runs entirely in your browser, so it keeps working without a network connection.

Free & private — why use this Regex Cheat Sheet

The Regex Cheat Sheet runs 100% client-side in your browser. Your data is never uploaded to a server, no account is required, and the tool is completely free. It works offline once the page has loaded and is part of a growing collection of privacy-first developer utilities.

More regex tools