Regex Cheat Sheet 2026: The Complete Regular Expression Reference
A comprehensive regex cheat sheet with syntax, examples, and common patterns. Copy-paste ready regular expressions for email, URL, phone, and more.
Try it now - free
Use BriskTool's free tool for this task
Regular expressions (regex) are powerful pattern-matching tools used in programming, text editors, and command-line utilities. This cheat sheet covers the syntax you need, with copy-paste ready patterns for common use cases.
Basic Syntax
| Symbol | Meaning | Example | Matches |
|---|---|---|---|
. | Any single character | h.t | hat, hot, h9t |
^ | Start of string | ^Hello | "Hello world" but not "Say Hello" |
$ | End of string | world$ | "Hello world" but not "worlds" |
* | 0 or more | ab*c | ac, abc, abbc, abbbc |
+ | 1 or more | ab+c | abc, abbc (not ac) |
? | 0 or 1 (optional) | colou?r | color, colour |
{n} | Exactly n times | a{3} | aaa |
{n,m} | Between n and m times | a{2,4} | aa, aaa, aaaa |
Character Classes
| Class | Meaning | Equivalent |
|---|---|---|
\d | Any digit | [0-9] |
\D | Any non-digit | [^0-9] |
\w | Word character | [a-zA-Z0-9_] |
\W | Non-word character | [^a-zA-Z0-9_] |
\s | Whitespace | [ \t\n\r\f] |
\S | Non-whitespace | [^ \t\n\r\f] |
[abc] | Any of a, b, or c | ā |
[^abc] | Not a, b, or c | ā |
[a-z] | Range: a through z | ā |
Common Patterns (Copy-Paste Ready)
Email Validation
^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$
Matches most standard email addresses. For production use, consider a more comprehensive RFC 5322 pattern or use your language's email validation library.
URL
https?:\/\/[\w\-]+(\.[\w\-]+)+[\/\w\-._~:?#\[\]@!$&'()*+,;=]*
Phone Number (US)
^\+?1?[\s\-]?\(?\d{3}\)?[\s\-]?\d{3}[\s\-]?\d{4}$
Matches: (555) 123-4567, 555-123-4567, +1 555 123 4567
Date (YYYY-MM-DD)
^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
IP Address (IPv4)
^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$
Strong Password
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$
Requires: lowercase, uppercase, digit, special character, 8+ characters.
Lookaheads and Lookbehinds
| Type | Syntax | Meaning |
|---|---|---|
| Positive lookahead | X(?=Y) | X followed by Y |
| Negative lookahead | X(?!Y) | X not followed by Y |
| Positive lookbehind | (?<=Y)X | X preceded by Y |
| Negative lookbehind | (? | X not preceded by Y |
Tips for Writing Better Regex
- Start simple: Build your pattern incrementally, testing at each step.
- Be specific: Use
\dinstead of.when you expect digits. More specific patterns are faster and less error-prone. - Use non-greedy quantifiers:
.*?instead of.*to match as little as possible. - Comment complex patterns: Use the verbose flag (
xin most languages) to add comments. - Test with edge cases: Empty strings, special characters, very long input, and Unicode text.
Test your patterns live with our free regex tester ā see matches highlighted in real-time as you type.