#patterns
5 pages tagged patterns.
re
Python's built-in regex module — compile vs not, match/search/findall/finditer/sub, named groups, lookarounds, verbose mode (re.X), and how it differs from PCRE.
PCRE
PCRE2 syntax reference — character classes, quantifiers, anchors, groups, lookarounds, backreferences, flags, and advanced features used in grep, sed, nginx, PHP, and dozens of other tools.
Discriminated Unions
Discriminated unions model finite states with a shared literal tag, enabling exhaustive narrowing in switch statements, Result-style error handling, reducer actions, and pattern-matched API responses.
Declaration Merging
Deep dive into TypeScript declaration merging — interface merging, namespace + class, namespace + function, module augmentation, global augmentation, and the Express Request pattern.
Branded Types
Branded (a.k.a. nominal, opaque, tagged) types add a phantom marker to a primitive so the compiler refuses to mix two strings — useful for IDs, units, validated input, and money. Covers hand-rolled brands, type-fest's Opaque/Tagged, Zod's .brand(), class-based brands, and runtime validation pairings.