← Cheat Sheets

Regex Groups, Lookarounds and Flags

Advanced regular expression features.

# Regex Groups, Lookarounds and Flags

Advanced regular expression features.

| Syntax | Meaning |
|---|---|
| `(abc)` | Capture group |
| `(?:abc)` | Non-capturing group |
| `(?<name>abc)` | Named group |
| `\1` | Back-reference to group 1 |
| `a(?=b)` | a followed by b (lookahead) |
| `a(?!b)` | a not followed by b |
| `(?<=b)a` | a preceded by b (lookbehind) |
| `(?<!b)a` | a not preceded by b |
| `.*?` | Lazy match (as few as possible) |
| `\b` / `\B` | Word boundary / not boundary |

**JavaScript flags:** `g` global, `i` ignore case, `m` multiline, `s` dot matches newline, `u` unicode.