Regex Cheat Sheet
Find and copy JavaScript RegExp tokens without mixing syntax from another regular-expression dialect.
Privacy: your files never leave your device. All processing happens locally in your browser.
How to use
- 1.Enter a token or concept such as \d, lookbehind, Unicode, lazy, or named in the search field.
- 2.Choose a category to narrow the JavaScript-specific entries, then review the token, meaning, and runnable-style example.
- 3.Select Copy on one row to place only that exact RegExp token on the clipboard.
About Regex Cheat Sheet
Regex Cheatsheet is a focused reference for the regular-expression syntax implemented by JavaScript RegExp. It contains 44 selected entries across characters, character classes, groups and references, quantifiers, assertions, and flags. Every row includes a category, the exact token, a concise meaning, and a JavaScript example. Search and filtering run entirely in the current browser tab. No query, selected category, copied token, or other input is uploaded to Lizely or another service.
The dialect boundary is explicit. This table describes ECMAScript regular expressions, not PCRE, Perl, Python, .NET, Java, RE2, POSIX basic or extended expressions, a shell glob, or a text editor's custom syntax. Those systems overlap with JavaScript but differ in important areas. A token that works elsewhere may be rejected by JavaScript or may carry different semantics. The entries here are checked against the ECMAScript RegExp pattern grammar and cross-checked with MDN's JavaScript-specific documentation. When code will run in a particular browser, embedded runtime, or older Node.js version, also verify that environment's feature support.
Character entries cover dot, ASCII digit and word escapes, whitespace escapes, and Unicode property escapes. In JavaScript, \d means the ASCII digits 0 through 9; it is not presented as a shortcut for every Unicode decimal digit. Likewise, \w primarily covers ASCII letters, ASCII digits, and underscore, with a documented Unicode-aware case-folding nuance when the i and u flags are combined. To match Unicode properties such as Letter, use a property escape like \p{Letter} with the u or v flag. Its complement is \P{Letter}. The table does not silently imply that property escapes work without Unicode-aware mode.
Character-class rows distinguish a listed class such as [abc], a negated class such as [^abc], and an inclusive range such as [a-z]. Escape rows include two-digit hexadecimal, four-digit UTF-16 code-unit, and braced Unicode code-point forms. The braced code-point form requires u or v. Examples are written as JavaScript regular-expression literals so the necessary slash delimiters and flags remain visible, while the Copy button copies only the token shown in the Token column. This makes the copied result useful inside an existing pattern without adding an unwanted example or explanation.
Grouping rows separate numbered captures, named captures, and non-capturing groups. They also distinguish numbered backreferences such as \1 from named backreferences such as \k<name>. Alternation is shown as x|y. These are not interchangeable: a non-capturing group controls precedence without adding a capture slot, while a backreference matches the same text captured earlier. The examples deliberately use JavaScript APIs such as RegExp.prototype.test and RegExp.prototype.exec rather than syntax borrowed from a command-line engine.
Quantifier rows cover zero-or-more, one-or-more, optional, exact count, lower-bounded count, bounded count, and lazy behavior. The default forms are greedy. Adding ? after a quantifier makes that quantifier lazy; it does not make the underlying token optional in that position. Assertions include start and end anchors, word and non-word boundaries, positive and negative lookahead, and positive and negative lookbehind. JavaScript lookbehind is written (?<=...) or (?<!...). It is not reversed into a lookahead form, and the assertion checks text before the current position without consuming that preceding text.
The flag section lists d, g, i, m, s, u, v, and y. The s flag lets dot match line terminators. The m flag changes how ^ and $ treat line boundaries. The g flag enables global matching behavior and affects lastIndex in stateful operations, while y requires a match at lastIndex. The d flag exposes match indices. The u flag enables Unicode-aware matching and code-point escapes. The newer v flag enables UnicodeSets behavior, including class-set operations and properties of strings; JavaScript does not allow u and v on the same RegExp. The table states that incompatibility instead of suggesting that flags can always be combined freely.
Use the search box when you know either a symbol or a concept. Searching \d finds the exact digit token, while terms such as lookbehind, Unicode, lazy, named, or line terminator find meanings and examples. Choose a category to narrow the current result set. Filters combine, and the displayed count always reports the complete number of matches; there is no hidden result cap. If nothing matches, the tool shows an explicit empty state. Changing the search or category invalidates an older clipboard job and clears its status, so a late clipboard response cannot describe a different filtered view.
Each Copy button requests clipboard access for one token. A job identifier ensures that only the newest copy attempt may publish success or failure, and component cleanup prevents a late clipboard promise from updating an unmounted page. Browser clipboard permission can still be denied. In that case, the tool reports a recoverable error rather than claiming that the token was copied. The cheat sheet is a quick syntax reference, not a regex validator, security analyzer, compatibility database, or guarantee that a pattern is efficient. Test real patterns against representative inputs, avoid uncontrolled backtracking on untrusted text, and use the related Regex Tester when behavior matters.
Methodology & sources
The table is a fixed, curated JavaScript RegExp reference with 44 unique token keys and six non-empty categories. Every entry must contain category, token, meaning, and JavaScript example. ECMAScript's RegExp pattern grammar is the normative source; MDN's JavaScript cheat sheet and RegExp reference independently cross-check practical wording, examples, and flags. Tests enforce table length, unique tokens, exact categories, required text, 12 independently transcribed golden entries, representative JavaScript runtime behavior, combined search and category filtering, explicit empty results, and clipboard success and rejection paths. No syntax from another regex dialect is intentionally included.
Frequently asked questions
- Does this cheat sheet cover PCRE, Python, .NET, or other regex dialects?
- No. It is deliberately limited to JavaScript RegExp as defined by ECMAScript. Other engines can share tokens while differing in syntax, Unicode behavior, flags, and supported features.
- Do Unicode property escapes work without a flag?
- No. A property escape such as \p{Letter} requires the u or v flag in JavaScript. The v flag adds UnicodeSets behavior and cannot be combined with u on the same RegExp.
- What is the JavaScript syntax for lookbehind?
- Positive lookbehind is (?<=...) and negative lookbehind is (?<!...). They assert what precedes the current position without consuming that preceding text.
- What does the Copy button put on the clipboard?
- It copies only the exact token in that row, not the category, explanation, example, slash delimiters, or flags from the example.
Related tools
- Regex TesterTest JavaScript regex live β see every match, capture group, and named group highlighted as you type.
- JSON ValidatorCheck if JSON is valid, pinpoint syntax errors by line and column, and see a structure diagnostic, in-browser.
- JSON FormatterFormat, minify, and validate JSON in your browser β pretty-print or compress with pinpoint error locations.
- Character CounterCount characters in real time and instantly see how much room is left for X/Twitter, SMS, Instagram, and SEO meta tags.
- ASCII TableLook up every standard 7-bit ASCII code with exact decimal, hexadecimal, octal, and binary values.
- BOM RemoverRemove exactly one leading U+FEFF from pasted decoded text locally while preserving every internal, trailing, or second leading occurrence.