Skip to content
NSNormandin SystemsTHE EVERYDAY TOOLBOXMain site
</>

Development / YOUR EVERYDAY TOOLBOX

Common Regex Cheatsheet

Cheatsheet for common regex patterns

✓ 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 Common Regex Cheatsheet

Common Regex Cheatsheet presents reusable regular-expression patterns for familiar text-matching tasks. Patterns are useful starting points, but validation requirements depend on context. Anchors, character classes, quantifiers, flags, and the selected engine determine what a pattern really accepts, especially for Unicode, newlines, and optional fields. 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. Find the closest pattern, define valid and invalid examples, and test it in the same regex engine used by the application.
  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 ^[0-9]+$ tested against 123 and 12a
RESULT / WHAT TO EXPECT
123 matches; 12a does not

The anchors require the entire tested value to consist of one or more ASCII digits in this simple example.

A copied pattern needs a requirement

Before adopting a pattern, define what should match and what should be rejected. A digit-only identifier, a human name, and an email address have very different rules, especially across languages and locales. Many compact examples intentionally cover only common cases. Use them to understand syntax and build a test set, not as unquestionable validators. Check whether anchors apply to the whole input and whether the chosen flags change case, line, or Unicode behavior.

Test failures as carefully as successes

A pattern that matches three valid examples can still accept many invalid ones. Add empty input, whitespace, extra punctuation, repeated separators, and a long near-match. Near-matches are particularly useful for exposing inefficient backtracking behavior. Keep the regex engine and API consistent with the application because matching, searching, and replacement functions return different results. Record the tests alongside the pattern so later edits can be evaluated against the actual requirement rather than visual resemblance to a familiar expression.

When this tool is useful

  • Draft a simple input-matching rule
  • Review anchors and character classes
  • Build a useful set of regex test cases

Tips for a better result

  • Test empty input, leading and trailing spaces, Unicode, and long input as well as ordinary valid samples.
  • 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

Is a common pattern a complete input validator?

A short pattern is rarely a complete validator for complex real-world identifiers. Avoid treating a convenient regex as authoritative for every email, URL, date, or international name.

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.