Developer Utilities

Regex Cheat Sheet

All tools

The core regex syntax on one screen, for when you cannot remember which flag lets the dot match newlines.

How it works

Four simple steps

1

Open the card

The reference is shown as soon as the page loads.

2

Find the token

Scan six grouped lines: classes, anchors, quantifiers, groups and flags.

3

Copy the sheet

One click copies the whole card for your notes.

4

Try it out

Test the syntax on real text in the Regex Tester.

Regex Cheat Sheet

About Regex Cheat Sheet

You write regular expressions a few times a month, which is often enough to need them and rarely enough to forget the syntax. Is a non-capturing group written (?:...)? Which flag makes the dot cross line breaks? This page keeps the answers on one short card.

The sheet is six lines of plain text. It covers the shorthand classes (. for any character except newline, plus \d, \w and \s), the ^ and $ anchors and the \b word boundary, the quantifiers *, + and ? along with the {n}, {n,} and {n,m} forms, character classes and negated classes, capturing and non-capturing groups, \1 backreferences and | alternation. The last line lists the JavaScript flags: g for global, i for ignore case, m for multiline, s for dotAll and u for Unicode. The Copy button puts the whole card on your clipboard for a notes file or README.

It is deliberately short, so lookarounds, named groups, lazy quantifiers and Unicode property escapes are not on it. When you want to try a token rather than read about it, open the interactive regex tester, and if a pattern needs a quick symbol-by-symbol gloss, the regex symbol explainer lists what it uses. More text and encoding utilities live in the developer tools collection.

The card is static text built into the page, so it makes no further requests once loaded.

Keyboard shortcut

Ctrl Enter - Run tool
FAQ

Frequently asked questions

See all FAQs

Answers for this tool. For site-wide help, open the FAQ hub.

m makes ^ and $ match at the start and end of every line instead of only the whole string. s, also called dotAll, lets . match newline characters. They solve different problems and are often used together on multi-line text.

Use (?:...) when you need grouping for alternation or a quantifier but do not need the matched text afterwards. It keeps group numbers stable, so

and \1 still point at the groups you care about.

Mostly. Python and PCRE share nearly all of it, though flags are written differently there (re.I, re.M and re.S in Python). POSIX tools such as plain grep do not understand \d unless you switch to the -P option.

View more FAQs

Related tools

View all

Cron Calendar

Explain cron expressions and preview the next run times in any timezone.

Open

CSV to SQL

Infer column types and generate CREATE TABLE + INSERT statements from CSV.

Open

SQL Query Builder

Build SELECT queries visually and reverse-parse SQL into a structure tree.

Open

Log Pattern Miner

Cluster log lines into templates, surface anomalies, and mask PII locally.

Open

Explore 321 free tools

Everything you need as a developer, marketer or creator - in one beautiful place.

Browse all tools