MENU

REGEX CHEATSHEET

Quick reference for regular expression syntax. Common patterns and examples.

Character Classes

PatternDescription
.Any character except newline
\dDigit (0-9)
\DNot a digit
\wWord character (a-z, A-Z, 0-9, _)
\WNot a word character
\sWhitespace
\SNot whitespace

Anchors

PatternDescription
^Start of string
$End of string
\bWord boundary
\BNot word boundary

Quantifiers

PatternDescription
*0 or more
+1 or more
?0 or 1
{3}Exactly 3
{3,}3 or more
{3,5}Between 3 and 5

Groups & Lookaround

PatternDescription
(abc)Capture group
(?:abc)Non-capturing group
(?=abc)Positive lookahead
(?!abc)Negative lookahead

Common Patterns

PatternDescription
[a-z]Lowercase letter
[A-Z]Uppercase letter
[0-9]Digit
[a-zA-Z]Any letter
[^abc]Not a, b, or c

Example Patterns

Email:

[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}

URL:

https?://[^\s/$.?#].[^\s]*

Phone (US):

\d{3}-\d{3}-\d{4}

Hex Color:

#[0-9a-fA-F]{6}