HomeRegex Cheat Sheet

Regex Cheat Sheet

Online regex cheat sheet with syntax reference, common patterns, and live matching test

Live Test

Enter a pattern to start testing

Basic Syntax

Character Classes

Quantifiers

Groups & Backreferences

Assertions

Common Patterns



Documentation

About Regex Cheat Sheet

This tool provides categorized regex syntax references with examples and a built-in tester for quick pattern building.

Key Features

  • Categorized Reference: Character classes, quantifiers, groups, and assertions.
  • Example-first Learning: Each rule includes practical examples.
  • Live Test Panel: Try pattern + flags and inspect matches instantly.
  • Flag Support: Common flags like g, i, m, s, and u.

Recommended Workflow

  1. Define your goal (validate, extract, or replace).
  2. Build base patterns with classes + quantifiers.
  3. Add groups, boundaries, or assertions for precision.
  4. Validate edge cases in the test panel.

Common Syntax Examples

Pattern Meaning Example
\\d+ one or more digits extract 123
^[a-z]+$ lowercase letters only username validation
`(foo bar)` alternation
(?<=@)\\w+ positive lookbehind extract email segment

FAQ

Are regex rules identical across languages?

Not exactly. JavaScript, Python, and Java differ in support for assertions, named groups, and engine behavior.

Why does a pattern work here but fail in production?

Usually due to runtime version, regex engine differences, or unsupported flags/features.