Regex & Text
Regex Cheat Sheet
Use this compact JavaScript regex reference to recall common tokens, then test the complete pattern against positive and negative examples.
Published
Interactive reference
Find a token, then test it
Choose Try in any row. One shared Regex Tester below receives the matching preset.
Character Classes
.Any character except a line terminator\d / \DDigit / non-digit\w / \WWord character / non-word character\s / \SWhitespace / non-whitespace[abc]One listed character[^abc]One character not listed[a-z]One lowercase ASCII letterAnchors
^Start of input or line with m$End of input or line with m\bWord boundaryQuantifiers
*Zero or more+One or more?Zero or one{n}Exactly n{n,}At least n{n,m}From n to m*? / +?Lazy repetitionGroups
(abc)Capture a group(?:abc)Group without capturinga|bMatch either alternative(?<name>abc)Named capture in the current JavaScript engineEscaping
\.Literal dot\*Literal asterisk\?Literal question mark\\Literal backslashFlags
gFind every matchiIgnore casemMake anchors line-awaresLet dot match line terminatorsuUnicode-aware parsingySticky matching from the current lastIndexIn JavaScript strings and JSON, a regex backslash needs an additional string-level escape.
Practice with the full tool
Test your own regex
Move from reference syntax to your real pattern, test text, flags and matches.