Free Regex Cheat Sheet & Pattern Builder

Visual regex reference with click-to-insert patterns, live preview, common patterns library, and code export. 100% client-side — your data stays private.

Regex Cheat Sheet

/ /
Character Classes
Quantifiers
Anchors
Groups & Escape

How to Use the Regex Cheat Sheet

  1. Click pattern buttons to insert regex tokens into the pattern builder.
  2. Type a test string and see matches highlighted in real time.
  3. Use common patterns as starting points for emails, URLs, dates, etc.
  4. Choose regex flags (g, i, m) from the dropdown.
  5. Export your pattern as JavaScript, Python, Go, or Java code.

How It Works

A regular expression is built from three core building blocks:

  • Character Classes — Define what type of character to match. For example, \d matches any digit, \w matches word characters (letters, digits, underscore), and [abc] matches any character in the set.
  • Quantifiers — Control how many times the preceding element is matched. + means one or more, * means zero or more, and {n,m} specifies an exact range.
  • Anchors — Pin the match to a position rather than consuming characters. ^ anchors to the start of the string, $ to the end, and \b to a word boundary.

Combine these building blocks to form patterns. For example, ^\d{4}-\d{2}-\d{2}$ matches a date string like 2025-07-06 by anchoring to start/end, requiring exactly four digits, a hyphen, two digits, a hyphen, and two more digits.

Character Classes

Pattern Description Example Match
\dAny digit (0-9)3, 9
\DAny non-digit charactera, @, space
\wWord character (a-z, A-Z, 0-9, _)A, 7, _
\WAny non-word character!, space, @
\sWhitespace (space, tab, newline)space, \t
\SAny non-whitespace charactera, 5, !
[abc]Any character in the seta, b, c
[^abc]Any character NOT in the setd, 1, @
[a-z]Any character in the rangea, m, z

Quantifiers

Pattern Description Example Match
*Zero or more of the preceding element"" (empty), "aaa"
+One or more of the preceding element"a", "aaaa"
{n}Exactly n occurrences{3} matches "123" in "abc123xyz"
{n,}At least n occurrences{2,} matches "ab", "abcd"
{n,m}Between n and m occurrences (inclusive){2,4} matches "ab", "abc", "abcd"
?Optional (zero or one)"colou?r" matches "color" and "colour"

Common Patterns

Use Case Regex Pattern Example
Email Validation[\w.+-]+@[\w-]+\.[\w.]+user@example.com
Phone Number\+?[\d\s()-]{7,}+1 (555) 123-4567
URLhttps?:\/\/[\w\-._~:/?#\[\]@!$&\'()*+,;=%]+https://example.com
Date Format (YYYY-MM-DD)\d{4}-\d{2}-\d{2}2025-07-06

Why Use This Regex Tool

Regular expressions are powerful but notoriously hard to remember. This visual cheat sheet lets you browse patterns by category and insert them with a click — no memorization required.

The live preview shows you exactly what your regex matches in real time, eliminating the trial-and-error cycle. Export directly to your preferred language and paste into your code.

Frequently Asked Questions

g — global: find all matches, not just the first. i — case-insensitive. m — multiline: ^ and $ match line starts/ends, not just string start/end.

Check for escaped special characters (e.g., \. instead of .), ensure the g flag is set for multiple matches, and verify your test string matches the expected format.

Basic patterns are compatible across most languages. However, advanced features like lookaheads or named groups have syntax differences between JavaScript, Python, Go, and Java. The export feature generates language-specific code.

Use Cases

Syntax Reference

Quick regex syntax reference with click-to-insert patterns for common operations.

Quantifier Lookup

Look up regex quantifiers like *, +, ?, and {n,m} for pattern construction.

Character Classes

Find regex character classes for matching digits, words, whitespace, and custom sets.

Pattern Building

Build regex patterns from a visual reference without memorizing complex syntax.

Anchors & Groups

Learn regex anchors, groups, and lookaheads with interactive examples and export.