Regex Cheat Sheet
Quick reference for regular expressions. Click any pattern to copy.
Characters
.Any character except newline\.Literal dot\dDigit [0-9]\DNot a digit\wWord char [a-zA-Z0-9_]\WNot a word char\sWhitespace\SNot whitespace\bWord boundary\BNot a word boundaryQuantifiers
*0 or more+1 or more?0 or 1{3}Exactly 3{3,}3 or more{3,5}3 to 5*?Lazy 0++?Lazy 1+Groups & Lookaround
(abc)Capture group(?:abc)Non-capturing group(?=abc)Positive lookahead(?!abc)Negative lookahead(?<=abc)Positive lookbehind(?<!abc)Negative lookbehindAnchors
^Start of string$End of string\AStart of string (multiline)\ZEnd of string (multiline)Character Classes
[abc]a, b, or c[^abc]Not a, b, or c[a-z]a to z[A-Z]A to Z[0-9]0 to 9[a-zA-Z]Any letterFlags
gGlobaliCase insensitivemMultilinesDotall (. matches \n)uUnicodeyStickyCommon Patterns
^\S+@\S+\.\S+$Email (basic)^https?://URL^\d{3}-\d{3}-\d{4}$US Phone^\d{5}(-\d{4})?$US Zip^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$Hex Color