Skip to content
NSNormandin SystemsTHE EVERYDAY TOOLBOXMain site
</>

Development / YOUR EVERYDAY TOOLBOX

Regex cheatsheet

Javascript Regex/Regular Expression cheatsheet

✓ Free to use✓ No account neededHow to use this tool ↓
YOUR WORKSPACESee an example ↗

Opening your tool…

Runs in your browser. Check important results and keep a copy of your original files.

THE PRACTICAL GUIDE · NORMANDIN SYSTEMS

Get more from Regex cheatsheet

Regex Cheatsheet summarizes JavaScript regular-expression syntax including character classes, quantifiers, groups, anchors, and flags. A regular expression matches a language of strings, while the surrounding API determines whether you obtain a boolean, one match, or many matches. Flags can change case handling, Unicode interpretation, and the meaning of anchors, so include them in the test case. A cheatsheet works best as a memory aid while you practice a concrete task. Read the command or syntax together with its arguments, placeholders, and surrounding context. Similar-looking options can have very different meanings, and an example written for one platform or version may need adjustment elsewhere. Keep the reference beside a small test case, use read-only examples first when possible, and check the relevant help output before applying an unfamiliar command to valuable files or a running service.

Guide updated October 13, 2026

How to use this tool

  1. Identify the operation you want to perform and find the matching section of the reference. Read the whole example before copying any part of it.
  2. Choose the syntax construct you need and test it with both matching and deliberately nonmatching examples in JavaScript.
  3. Review the example below and compare its expected behavior with a small sample of your own input before continuing.
  4. Try the adapted example on a small test case, compare the result with the explanation, and save the command with a note about the context in which it works.

SEE IT IN PRACTICE

A worked example

EXAMPLE INPUT
Pattern ^cat$ tested against cat and cats
RESULT / WHAT TO EXPECT
cat matches; cats does not

The anchors constrain the pattern to the complete tested string for this basic example without multiline behavior.

Literal syntax and string syntax add different escaping

A JavaScript regex literal and a string passed to a regex constructor are interpreted through different layers. A backslash needed by the regex may itself need escaping in the surrounding string. Keep those forms distinct when adapting a reference example. Test the exact expression form used by the application, including flags. A pattern that works in an online field may fail in source code because the language string parser consumed an escape before the regex engine received it.

APIs and state affect matching

Searching for a match, testing a value, replacing text, and collecting all matches are different operations. Some flags can make repeated use of a regex object stateful through its lastIndex behavior, which matters in loops and reusable validators. Include empty input, line breaks, and Unicode in tests where relevant. Watch for pathological performance with long near-matches. The syntax reference helps construct an expression, but the surrounding JavaScript API and input limits determine whether it behaves reliably in the application.

When this tool is useful

  • Review grouping and quantifier syntax
  • Understand anchored matching
  • Prepare a focused regex test matrix

Tips for a better result

  • Test flags, empty input, line breaks, Unicode, and the exact JavaScript API that will use the expression.
  • Replace example paths, identifiers, and names deliberately. Copying a reference command unchanged can target a different file, branch, service, or environment from the one you intended.
  • Keep the source and the settings used for this result together. That makes a later comparison or correction easier, especially when another person needs to reproduce the same outcome.

Frequently asked questions

Can a regular expression have performance problems?

Some expressions can perform poorly on long or adversarial input. JavaScript escaping also differs between a regex literal and a pattern stored inside a string.

Does this page execute the examples?

The cheatsheet is a reference. You read its examples and use them in your own editor, terminal, or application. Understand the effect and adapt placeholders before running commands in an environment that contains important data.

What if an example behaves differently on my system?

Check your installed version, platform, shell, and configuration. Read the command help or language documentation for that environment. References summarize common behavior, while available options and defaults can vary between implementations.

What happens to the information I enter?

The utility processes your input in this browser. Some tools retain field values in browser storage or the URL; avoid entering secrets in shareable fields. Page and asset requests still go to the hosting provider. Read the privacy and offline-use notes for details.