Tips & Tricks
Regex Cheat Sheet: The 20 Patterns You'll Use Every Week
🔍
## The Regex You Actually Need
These 20 patterns cover 90% of real-world use cases.
## Validation Patterns
```
Email: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
URL: https?://(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}
IP Address: ^(\d{1,3}\.){3}\d{1,3}$
Phone (US): ^\+?1?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$
Zip Code: ^\d{5}(-\d{4})?$
```
## Text Matching
```
Whole word: \bword\b
Empty lines: ^\s*$
Repeated word: \b(\w+)\s+\1\b
```
## Code & Data
```
HTML tags: <[^>]+>
CSS hex color: #([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\b
JSON key: "([^"]+)"\s*:
```
## Date Patterns
```
YYYY-MM-DD: ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
Time HH:MM: ^([01]\d|2[0-3]):([0-5]\d)$
```
**Tip:** Use the Regex Tester to try all of these with your own input.