Developerยท8 min read
Regular Expressions Cheat Sheet โ The Only Regex Guide You Need
Regular expressions (regex) are one of the most powerful tools in a developer's toolkit โ and also one of the most confusing. This cheat sheet covers everything you need.
Basic Patterns
| Pattern | Meaning | Example |
|---|---|---|
. | Any character | h.t matches "hat", "hit", "hot" |
\d | Any digit | \d{3} matches "123" |
\w | Word character | \w+ matches "hello" |
\s | Whitespace | \s+ matches spaces, tabs |
^ | Start of string | ^Hello matches "Hello world" |
$ | End of string | world$ matches "Hello world" |
Quantifiers
| Pattern | Meaning |
|---|---|
* | 0 or more |
+ | 1 or more |
? | 0 or 1 |
{3} | Exactly 3 |
{2,5} | Between 2 and 5 |
Common Patterns
Email Validation
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
URL Validation
https?:\/\/[\w\-]+(\.[\w\-]+)+[\/\w\-.?&=%#]*
Phone Number (US)
^\+?1?[-.\s]?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$
IP Address
^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$
Test Your Regex
VedaWell's Regex Tester lets you build and test regular expressions with real-time matching, capture group highlighting, and a built-in cheat sheet. Free, no signup.
Try These Free Tools
90+ Free Browser Tools
All tools run locally in your browser. No downloads, no signups, complete privacy.
Browse All Tools โ