Regex Cheat Sheet
Searchable, interactive reference for regular expression syntax with live pattern testing and common regex patterns.
About This Tool
The Regex Cheat Sheet is a free, interactive reference for regular expression syntax that every developer needs at their fingertips. Instead of memorizing cryptic metacharacters or digging through documentation, you can search, filter by category, and click to copy any syntax token in seconds.
Every entry includes the syntax notation, a plain-English description, an example pattern, and sample matches so you can immediately understand what each construct does. Categories cover the full spectrum of regex: character classes like \d, \w, and [a-z]; quantifiers including *, +, ?, and {n,m}; anchors such as ^, $, and \b; grouping constructs for capture, non-capture, and named groups; lookahead and lookbehind assertions; and all six JavaScript regex flags.
The built-in "Try It Live" area lets you enter any pattern and test string to see matches highlighted in real time, complete with flag toggles for global, case-insensitive, multiline, dotall, unicode, and sticky modes. This makes it easy to experiment with patterns before using them in your code.
A quick reference section of common patterns covers email validation, URL matching, IP addresses, dates, phone numbers, and hex color codes — patterns you reach for repeatedly.
All processing runs entirely in your browser. No data is sent to any server, and no login or signup is required. If you need to test regex patterns more thoroughly with capture group inspection and replace preview, try the Regex Tester. For building cron expressions that also use pattern-like syntax, check out the Cron Expression Builder. And for another searchable reference tool, the HTTP Status Codes reference follows a similar interactive format.
How to Use
- Type a keyword into the search bar at the top — for example,
lookahead,digit, orquantifier. - Click a category badge (Character Classes, Quantifiers, Anchors, Groups, Assertions, Flags, Common Patterns) to filter the list.
- Click any entry row to expand it and view the syntax, example pattern, and example matches.
- Click the Copy Syntax button to copy the raw syntax token to your clipboard.
- Scroll down to the Try It Live section to enter your own regex pattern and test string.
- Toggle the flag buttons (g, i, m, s, u, y) to control matching behavior.
- Review the highlighted Results area to see which parts of your test string match the pattern.
Popular Regex Cheat Sheet Topics
FAQ
What regex syntax does this cheat sheet cover?
The cheat sheet covers all major JavaScript-compatible regex syntax: character classes (\d, \w, \s and their negations, ranges, sets), quantifiers (*, +, ?, {n}, {n,m}, lazy variants), anchors (^, $, \b), grouping (capture, non-capture, named groups, backreferences, alternation), lookahead and lookbehind assertions, all six flags (g, i, m, s, u, y), and common real-world patterns for emails, URLs, IPs, dates, phone numbers, and hex colors.
How do I search for a specific regex syntax?
Use the search bar at the top of the page to type any keyword. You can search by syntax (e.g., \d, (?=)), description terms (e.g., 'digit', 'lookahead'), or category name. You can also filter by category using the badge buttons to narrow results.
Can I test regex patterns on this page?
Yes. The 'Try It Live' section at the bottom lets you enter any regex pattern and test string. Matches are highlighted in real time. You can toggle flags (g, i, m, s, u, y) to control matching behavior. The match count is displayed above the results.
What is the difference between greedy and lazy quantifiers?
Greedy quantifiers (*, +, ?) match as many characters as possible, while lazy quantifiers (*?, +?, ??) match as few characters as possible. For example, given the string '<b>bold</b>', the greedy pattern '<.+>' matches the entire string, while the lazy pattern '<.+?>' matches just '<b>' and '</b>' separately.
Is my data safe?
Yes. This is a fully client-side tool. All regex processing runs entirely in your browser using the native JavaScript RegExp engine. No data is sent to any server, no cookies are stored, and no login is required.
What are lookahead and lookbehind assertions?
Lookahead (?=...) and lookbehind (?<=...) are zero-width assertions that check for a pattern ahead or behind the current position without consuming characters. Negative versions (?!...) and (?<!...) check that a pattern is NOT present. They are useful for matching patterns only in specific contexts, like matching digits only when followed by 'px'.
Can I copy regex syntax from the cheat sheet?
Yes. Click any entry to expand it, then use the Copy Syntax or Copy buttons to copy the syntax token or example pattern to your clipboard. A checkmark confirms the copy was successful.
Related Tools
Regex Tester
Test regular expressions with real-time match highlighting and capture groups.
Bash Cheat Sheet
Searchable bash command reference organized by category. File operations, text processing, networking, process management, variables, control flow, and string manipulation.
Crontab Cheat Sheet
Interactive crontab quick reference with searchable expressions, field breakdown, special characters, and next run times.
SQL Cheat Sheet
Interactive SQL reference with syntax, examples, and dialect-specific variations for PostgreSQL, MySQL, and SQLite.
Vim Cheat Sheet
Interactive Vim cheat sheet with search, mode and category filters. Browse 100+ Vim commands for Normal, Insert, Visual, and Command-line modes.