Reference
Regex cheat sheet
JavaScript regular expression syntax in one place: character classes, anchors, quantifiers, capture groups, lookaround assertions and the flags that change matching behaviour.
Classes
Anchors
Quantifiers
Groups
Lookaround
Flags
JS API
Things worth remembering
- Quantifiers are greedy by default. Add ? to make them lazy: .*? stops at the first match.
- Named groups read better than indexes: str.match(re).groups.year.
- Escape user input before building a RegExp, otherwise a stray ( throws a SyntaxError.