/
RegExLab

Interactive Regex Cheatsheet

Master Regular Expressions in Real-Time — a searchable, filterable reference for syntax across PCRE, Python, JavaScript, Java, and Go. Copy any snippet with one click.

Screenshot of the Interactive Regex Cheatsheet showing a searchable table of regex patterns with syntax highlighting

Browse by Category

Regex Syntax Categories

Jump straight to the pattern family you need. Each card links to a filtered view of the full cheatsheet table below.

Anchors & Boundaries

Match string positions — ^, $, \b, \B, \A, \Z. Essential for validating full lines, trimming whitespace, or locking patterns to word edges.

Quantifiers

Control repetition with *, +, {n,m}, and their lazy variants *?, +?. Includes possessive quantifiers for Java and PCRE.

Character Classes

Shorthand classes \d, \w, \s, POSIX bracket expressions like [[:alpha:]], and custom ranges. Covers Unicode property escapes \p{L} supported in Java, JS (with u flag), and Go.

Groups & Lookarounds

Capturing (…), non-capturing (?:…), named groups (?<name>…), lookaheads (?=…), and lookbehinds (?<=…). Compatibility matrix included for each engine.

Assertions & Flags

Inline modifiers (?i), (?m), (?s), engine-specific flags (PCRE's J for duplicated names, Go's case-insensitive ? prefix), and atomic grouping (?>…).

Common Patterns

Battle-tested recipes: email validation, IPv4/IPv6 matching, URL parsing, date formats (ISO 8601, US, EU), phone numbers, and credit-card Luhn-check patterns ready to paste into your codebase.

Full Reference

Searchable Regex Table

Filter by engine, category, or keyword. Every row is copyable — click the pattern column to grab the snippet instantly.

Pattern Description Category PCRE Python JavaScript Java Go
^\d{3}-\d{2}-\d{4}$ US Social Security Number (XXX-XX-XXXX) Common Patterns
\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b Standard email address (case-insensitive flag required) Common Patterns
(?<=\b\w{3})\w+ Lookbehind: word following a 3-letter word boundary Groups & Lookarounds ✅ (3.6+) ✅ (ES2018+)
\p{Lu}\p{Ll}+ Capitalized word (Unicode-aware) Character Classes ✅ (regex module) ✅ (with u flag)
(?i)^https?:// HTTP or HTTPS scheme at line start (inline case-insensitive) Assertions & Flags ❌ (use /i flag) ❌ (prefix with (?i) not supported; use regexp.MustCompile("(?i)https?://"))
\d{1,3}(\.\d{1,3}){3} IPv4 address (basic structural match; does not validate 0–255 range) Common Patterns
(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) ISO 8601 date with named capture groups Groups & Lookarounds
\w+@\w+\.\w{2,4} Simplified email (no special characters, 2–4 TLD) Common Patterns
[[:digit:]]{5}(-[[:digit:]]{4})? US ZIP code with optional 4-digit extension (POSIX class) Character Classes ✅ (re module, via \d equiv.)
^.{0,255}$ String length validation: max 255 characters Anchors & Boundaries
(?>\w+\s*) Atomic group: consume word + trailing spaces without backtracking Groups & Lookarounds
\d{4}(?=&nbsp;|,|-)\d{2}\d{2} Year followed by separator-aware date digits (lookahead) Groups & Lookarounds
[^<>"'\s]+ Non-whitespace token excluding HTML/quote characters Character Classes
\b\d{1,2}:\d{2}(?::\d{2})?(?:[AP]M)?\b 12-hour or 24-hour time with optional seconds and AM/PM Common Patterns
(?m)^# [^\n]+$ Markdown-level-1 heading (multiline mode) Assertions & Flags ✅ (with m flag) ✅ (with m flag)

Take It Offline

Download the Cheatsheet

Export the full reference as a printable PDF or a machine-readable JSON file. Updated quarterly — current version 2.4.1, last revised November 2024.

Need the raw Markdown source? It's open-source on GitHub under the MIT license. View on GitHub →