Skip to main content

Regex Patterns

Common regular expression patterns and syntax

Programming

Character Classes

.

Any character except newline

\d

Digit (0-9)

\D

Non-digit

\w

Word character (a-z, A-Z, 0-9, _)

\W

Non-word character

\s

Whitespace

\S

Non-whitespace

Anchors

^

Start of string/line

$

End of string/line

\b

Word boundary

\B

Non-word boundary

Quantifiers

*

0 or more

+

1 or more

?

0 or 1

{n}

Exactly n times

{n,}

n or more times

{n,m}

Between n and m times

Groups & Lookaround

(abc)

Capturing group

(?:abc)

Non-capturing group

(?=abc)

Positive lookahead

(?!abc)

Negative lookahead

(?<=abc)

Positive lookbehind

(?<!abc)

Negative lookbehind

Common Patterns

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

Email

^https?://[\w.-]+(?:/[\w.-]*)*$

URL

^\d{3}-\d{3}-\d{4}$

Phone (US)

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

Hex Color

Privacy-First Developer Toolkits - 35+ Browser-Based Tools