Regex Cheat Sheet
Comprehensive regular expression quick reference with 42 patterns across 7 categories. Search and click to copy.
Character Classes
Anchors
Quantifiers
Groups & References
Lookaround
Flags
Common Patterns
How to Use the Regex Cheat Sheet
- 1.Browse categories or use the search bar to find specific patterns, descriptions, or examples.
- 2.Click a category button to filter by topic (Character Classes, Quantifiers, Lookaround, etc.).
- 3.Click on any row to copy the pattern to your clipboard.
- 4.Use the Common Patterns section for ready-to-use regex for emails, URLs, dates, and more.
Frequently Asked Questions
What is a regular expression (regex)?
A regular expression is a sequence of characters that defines a search pattern. It is used for pattern matching in strings -- finding, replacing, or validating text. Regex is supported in virtually all programming languages and text editors.
What is the difference between greedy and lazy quantifiers?
Greedy quantifiers (*, +, {n,m}) match as much text as possible. Lazy quantifiers (*?, +?, {n,m}?) match as little as possible. For example, given "<b>bold</b>", the pattern <.*> (greedy) matches the entire string, while <.*?> (lazy) matches just "<b>".
What are lookahead and lookbehind?
Lookahead (?=...) and lookbehind (?<=...) are zero-width assertions. They check for a pattern without including it in the match. Positive variants assert the pattern exists; negative variants (?!...) and (?<!...) assert it does not exist.
How do I test my regex patterns?
You can use our Regex Tester tool at /regex-tester to test patterns with real-time matching and highlighting. Online tools like regex101.com also provide detailed explanations of each pattern component.