A compact JavaScript-oriented regex reference for common tokens, anchors, groups and quantifiers.
Common regex tokens
| Pattern | Meaning |
|---|---|
. | Any character except line terminators unless dotAll is enabled |
d | Digit |
w | Word character in JavaScript’s basic character class |
s | Whitespace |
^ / $ | Start / end anchors |
[abc] | One character from a set |
[^abc] | One character not in a set |
* / + / ? | 0+ / 1+ / optional repetitions |
{n,m} | Repeat from n to m times |
(...) | Capturing group |
(?:...) | Non-capturing group |
a|b | Alternation |
b | Word boundary |
Useful JavaScript flags
g global, i case-insensitive, m multiline, s dotAll, u Unicode mode and y sticky matching.
Flavor matters
Regex syntax differs across JavaScript, PCRE, Python, .NET and other engines. Test patterns in the engine where they will actually run.