โ† Back to Spider On The Web

Regex Cheat Sheet

Regular expressions quick reference

Characters

.
Any character
\d
Digit [0-9]
\D
Not a digit
\w
Word char [a-zA-Z0-9_]
\W
Not a word char
\s
Whitespace
\S
Not whitespace
\
Escape special char

Quantifiers

*
0 or more
+
1 or more
?
0 or 1 (optional)
{3}
Exactly 3
{2,5}
Between 2 and 5
{2,}
2 or more

Anchors & Boundaries

^
Start of string
$
End of string
\b
Word boundary
\B
Not word boundary

Groups & Ranges

(abc)
Capture group
(?:abc)
Non-capture group
[abc]
Any of a, b, or c
[^abc]
Not a, b, or c
[a-z]
Range: a to z
a|b
a OR b

Common Patterns

Email (simple)
^\w+@\w+\.\w+$
Matches: test@example.com
Phone (US)
\d{3}-\d{3}-\d{4}
Matches: 555-123-4567
URL
https?:\/\/[\w\.-]+
Matches: https://example.com
IP Address
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
Matches: 192.168.1.1
Hex Color
#[0-9A-Fa-f]{6}
Matches: #FF5733

๐Ÿงช Try It

Enter a pattern above
๐Ÿ’ก Pro Tip

Use regex101.com for detailed explanations and testing. It breaks down each part of your pattern and shows matches in real-time.