Skip to content

Regex Cheat Sheet

Last verified May 2026 — runs in your browser
Regex Cheatsheet
.

Any character except newline

Characters
\d

Digit [0-9]

Characters
\D

Non-digit

Characters
\w

Word char [A-Za-z0-9_]

Characters
\W

Non-word char

Characters
\s

Whitespace (space, tab, newline)

Characters
\S

Non-whitespace

Characters
\b

Word boundary

Characters
\B

Non-word boundary

Characters
\n \r \t

Newline, carriage return, tab

Characters
\\ \. \+

Escape special characters

Characters
[abc]

Any of a, b, c

Classes
[^abc]

Not a, b, or c

Classes
[a-z]

Range a to z

Classes
[A-Z0-9]

Uppercase letters or digits

Classes
[a-zA-Z]

Any letter

Classes
a?

0 or 1 of a (optional)

Quantifiers
a*

0 or more of a

Quantifiers
a+

1 or more of a

Quantifiers
a{3}

Exactly 3 of a

Quantifiers
a{2,}

2 or more of a

Quantifiers
a{2,5}

Between 2 and 5 of a

Quantifiers
a*?

Lazy (minimal) match

Quantifiers
.*?

Minimal any-char match

Quantifiers
^

Start of string (or line in /m)

Anchors
$

End of string (or line in /m)

Anchors
^word$

Exact match for "word"

Anchors
\A \Z

Start/end of string (not line)

Anchors
(abc)

Capturing group

Groups
(?:abc)

Non-capturing group

Groups
(?<name>abc)

Named capture group

Groups
\1 \2

Backreference to group 1, 2

Groups
\k<name>

Backreference to named group

Groups
a|b

a or b (alternation)

Groups
(?=abc)

Positive lookahead

Lookaround
(?!abc)

Negative lookahead

Lookaround
(?<=abc)

Positive lookbehind

Lookaround
(?<!abc)

Negative lookbehind

Lookaround
\d(?=px)

Digit followed by 'px' (px not included)

Lookaround
/pattern/i

Case-insensitive

Flags
/pattern/g

Global (all matches)

Flags
/pattern/m

Multiline (^ $ match lines)

Flags
/pattern/s

Dot matches newline

Flags
/pattern/u

Unicode mode

Flags
^\d+$

Only digits

Common Patterns
^[a-zA-Z0-9]+$

Alphanumeric only

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

Email address

Common Patterns
^https?:\/\/[^\s]+$

URL (http or https)

Common Patterns
^\+?[1-9]\d{1,14}$

E.164 phone number

Common Patterns
^\d{4}-\d{2}-\d{2}$

ISO date YYYY-MM-DD

Common Patterns
^([01]\d|2[0-3]):[0-5]\d$

Time HH:MM (24h)

Common Patterns
^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$

Hex color

Common Patterns
\b\d{1,3}(\.\d{1,3}){3}\b

IPv4 address

Common Patterns
^[a-z0-9]+(-[a-z0-9]+)*$

URL slug (kebab-case)

Common Patterns
(?=.*[A-Z])(?=.*\d).{8,}

Password: 8+ chars, 1 upper, 1 digit

Common Patterns
Showing 55 of 55 patterns

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 ·

Related guides