ToolZoneX
Blog

Regex Cheat Sheet

A categorized quick reference for regular expression syntax with a live pattern tester. Free online regex cheat sheet.

Quick Pattern Tester

Character Classes

PatternDescription
.Any character except newline
\dAny digit (0-9)
\DAny non-digit
\wWord character (letter, digit, underscore)
\WNon-word character
\sWhitespace (space, tab, newline)
\SNon-whitespace
[abc]Any of a, b, or c
[^abc]Any character except a, b, or c
[a-z]Any lowercase letter a through z

Quantifiers

PatternDescription
*Zero or more of the preceding token
+One or more of the preceding token
?Zero or one of the preceding token (optional)
{n}Exactly n occurrences
{n,}n or more occurrences
{n,m}Between n and m occurrences
*?Zero or more, non-greedy (lazy)
+?One or more, non-greedy (lazy)

Anchors & Boundaries

PatternDescription
^Start of string (or line, with the m flag)
$End of string (or line, with the m flag)
\bWord boundary
\BNot a word boundary

Groups & Alternation

PatternDescription
(abc)Capturing group
(?:abc)Non-capturing group
(?<name>abc)Named capturing group
a|bAlternation — matches a or b
(?=abc)Positive lookahead
(?!abc)Negative lookahead
(?<=abc)Positive lookbehind
(?<!abc)Negative lookbehind

Common Flags

PatternDescription
gGlobal — find all matches, not just the first
iCase-insensitive matching
mMultiline — ^ and $ match line boundaries
sDot matches newline characters too

Common Patterns

PatternDescription
^[\w.+-]+@[\w-]+\.[a-zA-Z]{2,}$Email address
^https?:\/\/[\w.-]+(?:\.[a-zA-Z]{2,})+[\w\-._~:/?#[\]@!$&'()*+,;=]*$URL (http/https)
^\+?[0-9]{7,15}$Phone number (digits, optional leading +)
^\d{5}(-\d{4})?$US ZIP code (5 or ZIP+4)
^#(?:[0-9a-fA-F]{3}){1,2}$Hex color code
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$Password: 8+ chars, upper, lower, digit

Free Regex Cheat Sheet — Common Patterns & Syntax

A categorized quick reference for regular expression syntax — character classes, quantifiers, anchors, groups, flags, and ready-to-use patterns for email, URL, phone, and more. Every pattern has a one-click copy button.

How to Use It

Browse the categorized tables below, or use the quick tester at the top to try a pattern against a sample string right away. Click the copy icon next to any pattern to grab it.

Example

Need an email-matching regex? Copy ^[\w.+-]+@[\w-]+\.[a-zA-Z]{2,}$ straight from the Common Patterns table below.

Common Use Cases

  • Looking up regex syntax you don't use often enough to memorize.
  • Grabbing a ready-made pattern for email, URL, or password validation.
  • Quickly testing whether a pattern matches a sample string before using it in code.

FAQs

Are these patterns guaranteed to cover every edge case?

No — patterns like the email and URL examples cover the vast majority of real-world cases but aren't exhaustive against every technically valid edge case in their respective specifications. For strict validation (like real email deliverability), pair regex checks with an actual verification step.

Does this tool support every regex flavor?

The reference and tester use JavaScript's regex engine (ECMAScript syntax). Most patterns here also work in PCRE-based languages like Python or PHP, but some advanced features may differ slightly.

Is my test data uploaded anywhere?

No — the quick tester runs entirely client-side in your browser. Nothing you type is sent to a server.