← Cheat Sheets
Regex Quantifiers and Character Classes
Count and classify characters.
# Regex Quantifiers and Character Classes
Count and classify characters.
| Syntax | Meaning |
|---|---|
| `*` | 0 or more |
| `+` | 1 or more |
| `?` | 0 or 1 |
| `{3}` | exactly 3 |
| `{2,}` | 2 or more |
| `{2,5}` | between 2 and 5 |
| `[abc]` | a, b or c |
| `[^abc]` | anything except a, b, c |
| `[a-z0-9]` | ranges |
| `\d` `\D` | digit / non-digit |
| `\w` `\W` | word char / non-word |
| `\s` `\S` | whitespace / non-whitespace |
| `.` | any char except newline |
| `^` `$` | start / end of line |
Escape special characters with a backslash: `\. \* \? \( \[`.