- Anchor
- The `^` and `$` metacharacters that constrain a regex to match from the start and end of a string rather than anywhere within it. `^` matches start, `$` matches end.
- Character class
- A set of characters matched by a single token, like `\d` for digits, `\w` for word characters, `\s` for whitespace, or `[A-Za-z]` for letters.
- Quantifier
- A regex token that specifies how many times the preceding element must occur, such as `{3,6}` for 3 to 6 times, `+` for one or more, `*` for zero or more, or `?` for optional.
- Greedy vs lazy
- Greedy quantifiers (default) match as much text as possible; lazy quantifiers (suffix `?`, e.g. `+?`) match as little as possible. Greedy `.*` between quotes consumes everything; lazy `.*?` stops at the next quote.
- Lookahead
- An assertion that checks what follows the current position without consuming it. Positive lookahead `(?=foo)` succeeds if `foo` is next; negative lookahead `(?!foo)` succeeds if `foo` is NOT next.
- Lookbehind
- An assertion that checks what precedes the current position. Positive lookbehind `(?<=foo)` and negative lookbehind `(?<!foo)`. Some older regex engines do not support lookbehind.
- Capture group
- Parentheses `(...)` that mark a sub-pattern for extraction. The matched text is available as group 1, 2, ... in your language's regex API. Use `(?:...)` for non-capturing grouping.
- Alternation
- The `|` operator chooses between alternatives. `cat|dog` matches either word. Alternation is low precedence, so `^cat|dog$` means '^cat' or 'dog$', not '^(cat|dog)$'.