Interactive regex reference with live pattern tester
Zero Dependencies Β· Works Offlineπ§ͺ Live Regex Tester
π€ Character Classes
| . | Any character (except newline) |
| \\d | Digit [0-9] |
| \\D | Not a digit [^0-9] |
| \\w | Word character [a-zA-Z0-9_] |
| \\W | Not a word character |
| \\s | Whitespace (space, tab, newline) |
| \\S | Not whitespace |
| [abc] | Any of a, b, or c |
| [^abc] | Not a, b, or c |
| [a-z] | Character range a to z |
π’ Quantifiers
| * | 0 or more (greedy) |
| + | 1 or more (greedy) |
| ? | 0 or 1 (optional) |
| {n} | Exactly n times |
| {n,} | n or more times |
| {n,m} | Between n and m times |
| *? | 0 or more (lazy) |
| +? | 1 or more (lazy) |
| ?? | 0 or 1 (lazy) |
π Anchors & Boundaries
| ^ | Start of string/line |
| $ | End of string/line |
| \\b | Word boundary |
| \\B | Not a word boundary |
π¦ Groups & References
| (abc) | Capturing group |
| (?:abc) | Non-capturing group |
| (?<name>abc) | Named capturing group |
| \\1 | Backreference to group 1 |
| \\k<name> | Backreference to named group |
| | | Alternation (OR) |
ποΈ Lookaround
| (?=abc) | Positive lookahead |
| (?!abc) | Negative lookahead |
| (?<=abc) | Positive lookbehind |
| (?<!abc) | Negative lookbehind |
β‘ Special Characters
| \\ | Escape special character |
| \\n | Newline |
| \\t | Tab |
| \\r | Carriage return |
| \\xHH | Hex character |
| \\uHHHH | Unicode character |
π© Flags
| g | Global β find all matches |
| i | Case-insensitive |
| m | Multiline β ^ and $ match line boundaries |
| s | Dotall β . matches newline |
| u | Unicode β enable Unicode support |
| y | Sticky β match at current position |
What Is the Regex Cheat Sheet?
The Regex Cheat Sheet is a free online interactive reference for regular expressions. It provides a comprehensive quick-reference table for regex metacharacters, quantifiers, anchors, groups, lookarounds, and flags, combined with a live pattern tester. Click any pattern in the reference to insert it into the tester. All processing runs locally in your browser.
Core Features
- Live Tester: Test regex patterns against sample text in real-time
- Click-to-Insert: Click any pattern in the cheat sheet to insert it into the tester
- Common Patterns: Pre-built patterns for email, URL, phone, and IP validation
- Match Highlighting: Visual highlighting of all matches in the test string
- Group Capture: Shows captured groups for each match
Common Regex Patterns
Email: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/
URL: /^https?:\\/\\/(www\\.)?[a-zA-Z0-9-]+\\.[a-zA-Z]{2,}(\\/\\S*)?$/
Phone (US): /^\\(?\\d{3}\\)?[-.\\s]?\\d{3}[-.\\s]?\\d{4}$/
IP Address: /^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/
Regex Best Practices
Use non-capturing groups (?:...) when you don't need to reference the group. Prefer character classes over alternation for single characters ([abc] vs a|b|c). Use anchors (^ and $) to prevent partial matches. Be careful with greedy quantifiers on large inputs β they can cause catastrophic backtracking. Test your patterns with edge cases including empty strings and special characters.
β FAQ
What is a regular expression?
A sequence of characters defining a search pattern for string matching, validation, and text parsing.
Greedy vs lazy quantifiers?
Greedy (*, +) match as much as possible. Lazy (*?, +?) match as little as possible.
What are lookaheads/lookbehinds?
Zero-width assertions that check what comes after/before without consuming characters.
Is my data uploaded?
No. All regex testing happens locally in your browser.
Which regex flavor?
JavaScript ECMAScript RegExp. Most patterns are compatible with PCRE, Python, and Java.
How to escape special characters?
Use backslash: \\. matches a literal dot, \\\\ matches a literal backslash.