Complete Regex (Regular Expressions) keyboard shortcuts and commands reference — 12 shortcuts across 1 categories. Quick reference cheat sheet for Windows & Mac.
Regular expressions are not a program but a notation, and the same dozen tokens appear in every implementation — grep, sed, Python, JavaScript, the search box of an editor. This page lists those tokens. The notes cover what differs between flavours and the two habits that prevent most regex bugs: anchoring and escaping.
| Shortcut | Action |
|---|---|
| . | Any character |
| \\d | Digit |
| \\w | Word char |
| \\s | Whitespace |
| ^ | Start of line |
| $ | End of line |
| * | Zero or more |
| + | One or more |
| ? | Zero or one |
| [abc] | Char class |
| (group) | Group |
| a|b | OR |
The most essential Regex (Regular Expressions) shortcuts are: . (Any character), \\d (Digit), \\w (Word char).
The Regex (Regular Expressions) shortcut for any character is ..
Print the Regex (Regular Expressions) cheat sheet and keep it next to your keyboard for the first week, then switch to active recall: open Shortcut Speedrun and practice Regex (Regular Expressions) shortcuts against the clock until they're automatic.
Yes — use My Stack to combine Regex (Regular Expressions) shortcuts with any other platform on this site into one printable reference, which is useful if your daily workflow spans several tools.
. matches any single character except (usually) a newline. \\d, \\w and \\s match a digit, a word character (letters, digits, underscore) and whitespace; their capitals match the opposite. [abc] is a character class — any one of those — and [a-z] a range, with [^…] for "anything but". *, + and ? repeat the preceding item zero or more, one or more, and zero or one times, and {2,5} gives exact counts. (group) captures for later reference and a|b is alternation, which binds loosely — (cat|dog)s needs the parentheses.
^ and $ anchor to the start and end of the line (or the whole string, depending on the multiline flag), and forgetting them is how \d+ "matches" a number inside a word. Repeats are greedy — they take as much as possible — so ".*" across "a" and "b" matches the whole span; the lazy form .*? stops at the first closing quote. Escape a metacharacter with a backslash to match it literally: \. for a dot, \( for a parenthesis.
Basic grep and sed need backslashes before +, ?, |, ( and ) unless run with -E; Perl-style engines (Python, JavaScript, PCRE, ripgrep) use them bare. Lookarounds ((?=…), (?<!…)) and named groups exist in the Perl family only. When a pattern works in one tool and not another, the flavour is the first suspect.
Open your assistant with this page preloaded as the source — great for follow-up questions like "which of these work in other apps?"