Regex Cheat Sheet
Free regex cheat sheet — quick reference for regex syntax, patterns, and flags. Character classes, quantifiers, anchors, groups, lookarounds, and more. Built-in quick tester to try patterns instantly.
| Pattern | Matches |
|---|
| Pattern | Matches |
|---|
| Pattern | Matches |
|---|
| Pattern | Matches |
|---|
| Flag | Meaning |
|---|
| Task | Pattern |
|---|
How to Use Regex Cheat Sheet
Find What You Need
Browse the cheat sheet by category — character classes, quantifiers, anchors, groups, lookarounds, and flags. Each entry shows the pattern syntax and what it matches.
Copy a Pattern
Click any regex pattern to copy it to your clipboard. Paste it directly into your code editor, IDE search, or our Regex Tester to experiment.
Test Your Regex
Use the built-in quick tester at the top to try patterns against sample text. See matches highlighted instantly as you type.
Frequently Asked Questions
What is regex?
Regex (regular expression) is a sequence of characters that defines a search pattern. It's used to find, match, extract, and replace text based on patterns rather than exact strings. Regex is supported in virtually every programming language — JavaScript, Python, Java, PHP, Ruby, Go — as well as text editors, IDEs, and command-line tools like grep and sed.
Why do I need a cheat sheet?
Regex syntax is powerful but not intuitive. Lookaheads (?=), lookbehinds (?<=), non-capturing groups (?:), and backreferences (\1) are easy to forget if you don't use them daily. A cheat sheet gives you the correct syntax instantly, saving time searching Stack Overflow for "regex match everything until character" for the hundredth time.
What regex flavor does this cheat sheet cover?
This cheat sheet covers JavaScript/ECMAScript regex syntax, which is the most widely supported flavor in web development. Most patterns work identically in Python (re module), Java (java.util.regex), and PHP (PCRE), but there are some differences — Python uses \A and \Z for string boundaries instead of ^ and $ in multiline mode; PCRE supports recursive patterns that JavaScript doesn't. Check your language's regex documentation for specifics.
How do I test if my regex works?
Use our Regex Tester tool — paste your pattern and test text, and matches are highlighted in real time. The tester shows full matches, capture groups, and match positions. This is faster than running code, getting unexpected results, and debugging. Always test regex against both positive cases (text that should match) and negative cases (text that should not match).
How to Use This Cheat Sheet
Regex doesn't need to be memorized. Even developers who write regex daily keep a reference handy. Click any pattern to copy it, then paste into your code or our Regex Tester to experiment.
Building Patterns Step by Step
- Start with anchors: Use ^ and $ to define where your match should start and end
- Define character classes: Use \\d for digits, \\w for words, or [custom] for specific sets
- Add quantifiers: Use + for one or more, * for zero or more, {n,m} for exact ranges
- Capture what you need: Wrap important parts in () to extract them from the match
- Test against edge cases: Empty strings, special characters, and boundary conditions