.
Any character except newline
\d
Digit [0-9]
\D
Non-digit
\w
Word char [A-Za-z0-9_]
\W
Non-word char
\s
Whitespace (space, tab, newline)
\S
Non-whitespace
\b
Word boundary
\B
Non-word boundary
\n \r \t
Newline, carriage return, tab
\\ \. \+
Escape special characters
[abc]
Any of a, b, c
[^abc]
Not a, b, or c
[a-z]
Range a to z
[A-Z0-9]
Uppercase letters or digits
[a-zA-Z]
Any letter
a?
0 or 1 of a (optional)
a*
0 or more of a
a+
1 or more of a
a{3} Exactly 3 of a
a{2,} 2 or more of a
a{2,5} Between 2 and 5 of a
a*?
Lazy (minimal) match
.*?
Minimal any-char match
^
Start of string (or line in /m)
$
End of string (or line in /m)
^word$
Exact match for "word"
\A \Z
Start/end of string (not line)
(abc)
Capturing group
(?:abc)
Non-capturing group
(?<name>abc)
Named capture group
\1 \2
Backreference to group 1, 2
\k<name>
Backreference to named group
a|b
a or b (alternation)
(?=abc)
Positive lookahead
(?!abc)
Negative lookahead
(?<=abc)
Positive lookbehind
(?<!abc)
Negative lookbehind
\d(?=px)
Digit followed by 'px' (px not included)
/pattern/i
Case-insensitive
/pattern/g
Global (all matches)
/pattern/m
Multiline (^ $ match lines)
/pattern/s
Dot matches newline
/pattern/u
Unicode mode
^\d+$
Only digits
^[a-zA-Z0-9]+$
Alphanumeric only
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ Email address
^https?:\/\/[^\s]+$
URL (http or https)
^\+?[1-9]\d{1,14}$ E.164 phone number
^\d{4}-\d{2}-\d{2}$ ISO date YYYY-MM-DD
^([01]\d|2[0-3]):[0-5]\d$
Time HH:MM (24h)
^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$ Hex color
\b\d{1,3}(\.\d{1,3}){3}\b IPv4 address
^[a-z0-9]+(-[a-z0-9]+)*$
URL slug (kebab-case)
(?=.*[A-Z])(?=.*\d).{8,} Password: 8+ chars, 1 upper, 1 digit
Regex Cheat Sheet — Anchors, Quantifiers, Lookarounds & Capture Groups
A searchable regex quick reference covering character classes, quantifiers, anchors, groups, lookaround, flags, and tested common patterns (email, URL, IP, date).
About this cheatsheet
A comprehensive regular expressions cheatsheet with syntax and ready-to-use patterns for common validations.
- 55+ regex patterns and operators
- Character classes and quantifiers
- Lookahead and lookbehind
- Flags (i, g, m, s, u)
- Common patterns: email, URL, IP, date
- One-click copy to clipboard
Free. No signup. Your inputs stay in your browser. Ads via Google AdSense (consent required).
By Marco B. ·