Regex Cheatsheet
Quick reference for Regular Expressions.
Character Classes
- Any character (except newline)
. - Word character [a-zA-Z0-9_]
\w - Digit [0-9]
\d - Whitespace
\s
Anchors
- Start of string
^ - End of string
$ - Word boundary
\b
Quantifiers
- 0 or more
* - 1 or more
+ - 0 or 1
? - Exactly 3
{3}
Groups & Ranges
- Capture group
(abc) - Any char in set
[abc] - Range (a to z)
[a-z] - Logical OR
a|b