Regex Cheat Sheet: Symbols and What They Mean
Updated November 2026
Written by the Toolpuffin team. Tools in this guide are tested in the browser.
Regular expression symbols look like noise until you know what each one does. This cheat sheet lists the ones you will meet most, with a short example for each, so you can read a pattern or write your own.
Characters
| Symbol | Meaning | Example |
|---|---|---|
| . | Any one character except a line break | a.c matches abc and a1c |
| \d | One digit, 0 to 9 | \d\d matches 42 |
| \w | One letter, digit or underscore | \w+ matches hello_1 |
| \s | One whitespace character: space, tab or line break | a\sb matches a b |
| [abc] | One of the characters inside the brackets | [aeiou] matches any vowel |
| [^abc] | Any one character except those inside the brackets | [^0-9] matches any non-digit |
| \. | A backslash makes a symbol literal | \. matches a real dot |
Repeating
| Symbol | Meaning | Example |
|---|---|---|
| * | Zero or more of the thing before it | ab*c matches ac, abc and abbc |
| + | One or more | ab+c matches abc and abbc, not ac |
| ? | Zero or one, so optional | colou?r matches color and colour |
| {n} | Exactly n times | \d{4} matches 2026 |
| {n,m} | Between n and m times | \d{2,4} matches 12, 123 and 1234 |
Positions
| Symbol | Meaning | Example |
|---|---|---|
| ^ | The start of the text, or of each line with the multiline flag | ^Hello matches Hello at the start |
| $ | The end of the text, or of each line with the multiline flag | end$ matches end at the end |
| \b | The edge of a word | \bcat\b matches cat but not concatenate |
Positions do not match a character. They match a place between characters.
Groups and choices
- (abc) groups characters together and remembers what it matched.
- cat|dog matches cat or dog.
- (?:abc) groups without remembering.
- (cat|dog)s? matches cat, cats, dog and dogs.
Flags
- g finds all matches, not just the first.
- i ignores upper and lower case.
- m lets ^ and $ work on each line.
- s lets the dot match line breaks too.
- u turns on full Unicode support.
The regex tester has a switch for each of these flags.
Try a symbol
- Open the regex tester and paste some text.
- Type a pattern from the tables.
- Check which parts are highlighted, and change the pattern to see what moves.
The tester uses the JavaScript flavour. Most symbols above work the same in other languages, but features such as lookbehind can differ.