RegEx Cheat Sheet & Generator

Generate common regular expressions dynamically or review anchors, quantifiers, and groupings with our interactive reference sheet.

Generated Regular Expression
/^.*$/i
Quick Templates
Custom Pattern Builder

RegEx Quick Reference

Character Classes

. Any single character except newline \d Any digit (0-9) \D Any non-digit character \w Alphanumeric character + underscore \W Non-alphanumeric character \s Whitespace (space, tab, newline) \S Non-whitespace character

Quantifiers

* 0 or more times + 1 or more times ? 0 or 1 time (optional) {n} Exactly n times {n,} n or more times {n,m} Between n and m times

Anchors

^ Start of line / string $ End of line / string \b Word boundary \B Non-word boundary

Groups & Ranges

(x) Capture group (?:x) Non-capturing group [abc] Any character inside bracket (a, b, or c) [^abc] Any character NOT inside bracket [a-z] Any lowercase letter range x|y Matches either x or y
Comprehensive Developer Guide Mastering Regular Expressions: Zero to Hero Guide

Explore the underlying mathematics, RFC specifications, and production best practices in our deep-dive tutorial.

Read Guide →

Regular Expression Theory & Pattern Matching Architecture

A Regular Expression (RegEx or RegExp) is a sequence of characters that specifies a search pattern in text. Originating in theoretical computer science (formal language theory and Stephen Kleene's regular sets), regular expressions are supported natively across every major programming language via state machine engines (Deterministic and Nondeterministic Finite Automata - DFA and NFA).

RegEx patterns power search-and-replace routines, form input validation (email addresses, phone numbers, UUIDs), log parsing, and data scraping. However, due to its dense, compact syntax containing meta-characters, quantifiers, anchors, and lookarounds, writing correct patterns can be challenging even for experienced developers.

Our RegEx Generator & Cheat Sheet provides a visual catalog of pre-built, production-tested regular expressions alongside an interactive builder to construct custom regex patterns with immediate verification.

Common Production RegEx Patterns Cheat Sheet

Standard regex patterns for everyday development tasks:

Regular Expression Engine Flags (g, i, m, s, u)

Regex flags alter the global matching behavior of the pattern:

Preventing Catastrophic Backtracking (ReDoS)

Regular Expression Denial of Service (ReDoS) occurs when an NFA regex engine encounters nested quantifiers over overlapping patterns (e.g. (a+)+$). When tested against a string of 30 "a" characters followed by an "x", the engine evaluates millions of combinations, freezing server CPUs. Always test patterns with regex profilers and avoid nested greedy quantifiers.

Common Production RegEx Patterns & Quantifier Greedy vs Lazy Mechanics

Constructing robust regular expressions requires an understanding of pattern quantifiers and boundary assertions. Quantifiers in regex engines are Greedy by default: patterns like <.*> match from the first < to the final > on the entire line, inadvertently matching multiple HTML tags simultaneously.

Appending a question mark creates a Lazy (Reluctant) Quantifier (<.*?>), causing the engine to halt matching at the earliest possible closing delimiter. Our cheat sheet and pattern generator provides instant, battle-tested regular expressions for common validation scenarios (emails, international phone numbers, URLs, IPv4 addresses, hex colors) with comprehensive flag configurations.

Standard Pre-Configured Validation Patterns

  • Email Validation (RFC 5322 Simplified): ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
  • IPv4 Address: ^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$
  • ISO 8601 Date: ^\d{4}-\d{2}-\d{2}$

Frequently Asked Questions

Greedy quantifiers (like .* or +) match as much text as possible. Appending a question mark (.*? or +?) makes them lazy, matching the smallest possible substring.

A lookahead (?=...) checks if a specific pattern follows the current position without including those characters in the matched result.

The official RFC 5322 email specification permits comments, quotes, and esoteric characters, resulting in a regex over 6,000 characters long. Practical web applications use simplified regexes combined with verification emails.

Yes. As you select or modify patterns, matches in sample text are highlighted instantly in your browser.

No. All regex compilation and matching occur 100% locally via the browser's native RegExp JavaScript engine.