Regex Cheat Sheet: Patterns You'll Actually Use
Regex is powerful but unreadable. Instead of memorizing every metacharacter, keep this cheat sheet of patterns you'll actually need.
Forget memorizing regex syntax. Here are the 15 patterns that cover 90% of real-world text extraction and validation.
Regex is powerful but unreadable. Instead of memorizing every metacharacter, keep this cheat sheet of patterns you'll actually need. Each one is tested, explained, and copy-paste ready.
Syntax Quick Reference
. Any character except newline
\d Digit (0-9)
\w Word character (a-z, A-Z, 0-9, _)
\s Whitespace (space, tab, newline)
^ Start of string
$ End of string
* Zero or more
+ One or more
? Zero or one (optional)
{n} Exactly n times
{n,m} Between n and m times
[abc] Any character in brackets
[^abc] Any character NOT in brackets
(...) Capture group
| OR operatorEmail Addresses
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}Matches most real-world email formats. Won't catch every edge case in the RFC spec, but works for 99% of actual email addresses.
URLs
https?://[\w.-]+(?:\.[a-zA-Z]{2,})(?:/[^\s]*)?Matches HTTP and HTTPS URLs. For a simpler version that captures most links:
https?://\S+Phone Numbers (US)
(?:\+1[-\s]?)?\(?\d{3}\)?[-\s.]?\d{3}[-\s.]?\d{4}Matches formats like: (555) 123-4567, 555-123-4567, 555.123.4567, +1 555 123 4567
Dates
// MM/DD/YYYY or MM-DD-YYYY
\d{1,2}[/-]\d{1,2}[/-]\d{2,4}
// ISO format: YYYY-MM-DD
\d{4}-\d{2}-\d{2}Numbers & Currency
// Integers and decimals
-?\d+\.?\d*
// Currency (US)
\$[\d,]+\.?\d{0,2}
// Percentage
\d+\.?\d*%Common Text Patterns
// IP address (v4)
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
// Hex color code
#[0-9a-fA-F]{3,8}
// Zip code (US)
\d{5}(-\d{4})?
// Extract text between quotes
"([^"]*)"
// Remove HTML tags
<[^>]*>Generate & Test Regex Instantly
Describe what you want to match in plain English — "extract all dollar amounts from this text" — and Formula Genius generates a tested regex pattern with explanations.