Visual regex workbench

Build, import, explain, test and share regex visually.

Regex guide

Regex Cheatsheet

A compact reference for the most useful regex tokens. Use it as a quick reminder while building or debugging regular expressions.

What is a regex cheatsheet?

A regex cheatsheet is a quick reference guide that summarizes the most common regular expression syntax, tokens and operators.

It helps beginners learn regex faster and allows experienced developers to quickly look up rarely used constructs.

The most important regex tokens to know

Most regular expressions are built using a small set of tokens such as character classes, quantifiers, groups and anchors.

Learning symbols like \d, \w, *, +, ?, ^ and $ covers a large percentage of real-world regex use cases.

Character classes explained

Character classes define which characters are allowed at a specific position in a match.

Examples include digits, letters, whitespace characters and custom sets such as [A-Z] or [0-9].

Understanding regex quantifiers

Quantifiers control how many times a character, token or group can appear.

Common quantifiers include *, +, ?, {3} and {1,10}, each providing different matching behavior.

Groups, alternation and anchors

Groups allow multiple tokens to be treated as a single unit, while alternation provides OR logic inside a pattern.

Anchors such as ^ and $ define where a match must start or end within a string.

Regex syntax differences between languages

Most regex syntax is shared across JavaScript, PHP, Python and PCRE, but some advanced features differ.

Lookbehind assertions, Unicode property escapes and named groups may not behave identically across regex engines.

How to learn regex efficiently

The best way to learn regex is to combine a cheatsheet with interactive testing.

Experimenting with patterns and immediately seeing matches helps build intuition much faster than memorizing syntax alone.

Anchors and boundaries

^ matches the start of a string or line, depending on multiline mode.

$ matches the end of a string or line.

\b matches a word boundary.

^hello\b
Quick test

Character classes

\d matches a digit. \w matches a word character. \s matches whitespace.

[A-Z] matches one uppercase ASCII letter. [^0-9] matches one non-digit.

[A-Za-z0-9_]+
Quick test

Quantifiers

? means optional, * means zero or more, + means one or more.

{3} means exactly three, {2,5} means between two and five.

\d{2,4}
Quick test

Groups and alternatives

(abc) captures a group. (?:abc) groups without capturing.

cat|dog matches either cat or dog.

(?:cat|dog)s?
Quick test

Lookarounds

(?=...) is a positive lookahead. (?!...) is a negative lookahead.

Lookbehind support depends on the regex engine.

\w+(?=:)
Quick test