Skip to content
ZeroServer.tools

Regex Cheat Sheet

Searchable regular expression reference, syntax cheat sheet, and interactive test playground.

Interactive Test Playground

6 matches found
Matches:quickbrownjumpsoverlazydogs

Anchors

PatternDescriptionActions
^Start of string (or line in multiline mode)
$End of string (or line in multiline mode)
\bWord boundary
\BNon-word boundary
\AStart of string (no multiline)
\ZEnd of string (no multiline)

Character Classes

PatternDescriptionActions
.Any character except newline
\dDigit [0–9]
\DNon-digit
\wWord character [A-Za-z0-9_]
\WNon-word character
\sWhitespace (space, tab, newline)
\SNon-whitespace
[abc]Character set — any of a, b, or c
[^abc]Negated character set
[a-z]Character range
[a-zA-Z]Case-insensitive range

Quantifiers

PatternDescriptionActions
*Zero or more (greedy)
+One or more (greedy)
?Zero or one (optional)
{n}Exactly n times
{n,}n or more times
{n,m}Between n and m times
*?Zero or more (lazy)
+?One or more (lazy)
??Zero or one (lazy)

Groups & Alternation

PatternDescriptionActions
(abc)Capture group — captures match
(?:abc)Non-capturing group
(?P<name>abc)Named capture group
a|bAlternation — a or b
\1Backreference to group 1

Lookahead & Lookbehind

PatternDescriptionActions
(?=abc)Positive lookahead — followed by
(?!abc)Negative lookahead — not followed by
(?<=abc)Positive lookbehind — preceded by
(?<!abc)Negative lookbehind — not preceded by

Flags

PatternDescriptionActions
gGlobal — find all matches (not just first)
iCase-insensitive match
mMultiline — ^ and $ match line boundaries
sDotall — . matches newline too
uUnicode — enables Unicode escapes
ySticky — match at lastIndex only
dIndices — report match indices

Special & Escape

PatternDescriptionActions
\nNewline
\tTab
\rCarriage return
\uXXXXUnicode code point
\xHHHex code point
\0Null character
\\Literal backslash

Visible Patterns

49

Active Category

all

Playground Status

6 Matches

Regular expression cheat sheet & reference

This regular expression reference sheet categorizes regex syntax elements including anchors, character classes, quantifiers, capture groups, lookarounds, and flags. Click any pattern's play icon to test it live inside the built-in browser regex evaluator.

To test complex regular expressions against multi-line text, visit our dedicated Regex Tester. To escape special characters in regex strings, try the Regex Escape Tool.

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Finding the syntax for a construct you use rarely.
  • Checking what a flag changes before adding it.
  • Learning lookahead and lookbehind syntax with examples.
  • Confirming what a shorthand character class actually includes.
  • Finding the right quantifier for a case.

Frequently Asked Questions

What is the difference between greedy and lazy quantifiers?
Greedy matches as much as possible then backtracks; lazy stops at the first opportunity. `<.*>` swallows a whole line of HTML where `<.*?>` matches one tag — the most common surprise for newcomers.
When should I use a non-capturing group?
Whenever you group for alternation or repetition but do not need the text. `(?:...)` keeps the capture numbering clean and avoids storing matches you will never read.
What are lookahead and lookbehind for?
Asserting context without consuming it — matching a word only when followed or preceded by something. Lookbehind support was historically patchy, though it is now available in modern JavaScript, Python and .NET.
Why does my regex hang on a long input?
Catastrophic backtracking — nested quantifiers such as `(a+)+` produce exponential paths on a near-match. It is a real denial-of-service vector, and the fix is to make the pattern unambiguous rather than to add a timeout.
Do regex flavours really differ that much?
Enough to matter. Word boundaries, Unicode property support, named group syntax and lookbehind all vary between PCRE, JavaScript, Python and POSIX — a pattern is not portable without testing.

Common errors and gotchas

  • Assuming one flavour, since lookbehind, named groups and unicode classes vary by engine.
  • Using a greedy quantifier where a lazy one was needed, which swallows far too much.
  • Forgetting that the dot excludes newlines unless a flag says otherwise.
  • Writing a pattern with nested quantifiers, which can backtrack catastrophically.
  • Copying a pattern without its flags, which changes its meaning entirely.

Related Developer Utilities tools

Private & free — this tool runs entirely in your browser.

IndieKitShip your Next.js startup in days.affiliate