← Cheat Sheets

Regex Basics

Regular expression building blocks with examples.

# Regex Basics

| Pattern | Matches |
|---|---|
| `.` | any character |
| `\d` `\w` `\s` | digit, word, space |
| `^` `$` | start, end |
| `*` `+` `?` | 0+, 1+, 0 or 1 |
| `{2,4}` | 2 to 4 times |
| `[a-z]` | character range |
| `(abc)` | group |
| `a|b` | a or b |

Example email-ish: `^[\w.+-]+@[\w-]+\.[\w.-]+$`