Regex Tokens Cheatsheet

Interactive regex token reference covering PCRE, JS, Python and .NET flavors.

A searchable regular-expression token reference covering character classes, anchors, quantifiers, groups and lookaround, with per-flavor support flags for PCRE, JavaScript, Python and .NET, plus a live tester.

What is the difference between greedy and lazy quantifiers?

Greedy quantifiers like * and + match as much as possible, then backtrack if needed. Adding a ? makes them lazy, so *? and +? match as little as possible. Possessive quantifiers like *+ match greedily and never backtrack, which can prevent catastrophic backtracking.

This is an interactive regular-expression token reference. It lists the metacharacters and constructs you use to build patterns — character classes, anchors, quantifiers, groups and lookaround — and shows which of the major flavors (PCRE, JavaScript, Python and .NET) support each one. A built-in tester runs your pattern live so you can confirm what it matches.

How it works

A regular expression is a compact language for describing text patterns. Tokens fall into a few families: character classes match sets of characters (\d, [a-z], .), anchors match positions rather than characters (^, $, \b), quantifiers control repetition (*, +, {n,m}), groups capture or organise sub-patterns ((...), (?:...), (?<name>...)), and lookaround asserts what does or does not surround a position without consuming it ((?=...), (?<!...)). The reference marks each token with the flavors that accept it, because syntax such as named groups, possessive quantifiers and inline flags varies between engines.

Using the live tester

The tester compiles your pattern with the browser’s JavaScript engine and reports every match. Add flags such as g for global, i for case-insensitive, m for multiline and s for dotall. If the pattern is invalid you will see the engine’s error message. Because the engine is JavaScript, PCRE- or .NET-specific constructs may not be valid there — use the flavor column to keep your patterns portable. Everything runs in your browser; your pattern and text are never uploaded.