Regex Cheat Sheet
A searchable reference of common regular expression syntax — character classes, anchors, quantifiers, groups, lookaround, and flags — with examples.
| Category | Pattern | Description | Example |
|---|---|---|---|
Character classes | . | Any character except newline | a.c matches abc |
Character classes | \d | Digit (0-9) | \d+ matches 123 |
Character classes | \D | Non-digit | \D+ matches abc |
Character classes | \w | Word character (letters, digits, underscore) | \w+ matches hello_1 |
Character classes | \W | Non-word character | \W matches @ |
Character classes | \s | Whitespace | \s+ matches spaces/tabs |
Character classes | \S | Non-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 | \b | Word boundary | \bcat\b matches whole word cat |
Anchors | \B | Non-word boundary | \Bcat matches concatenate |
Quantifiers | * | 0 or more | ab*c matches ac, abc, abbc |
Quantifiers | + | 1 or more | ab+c matches abc, abbc |
Quantifiers | ? | 0 or 1 (optional) | ab?c matches ac or abc |
Quantifiers | {n} | Exactly n times | a{3} matches aaa |
Quantifiers | {n,} | n or more times | a{2,} matches aa, aaa, ... |
Quantifiers | {n,m} | Between n and m times | a{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|b | Alternation (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 | g | Global — find all matches | /abc/g |
Flags | i | Case-insensitive | /abc/i matches ABC |
Flags | m | Multiline — ^ and $ match line boundaries | /^abc/m |
Flags | s | Dot matches newline too | /a.b/s |
Flags | u | Unicode 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.