Developer Reference100% Free Quick ReferenceUpdated 2026-09-04

Regular Expressions (Regex) Cheatsheet & Syntax Quick Reference

The complete, interactive Regular Expressions syntax reference with battle-tested patterns for emails, URLs, phones, and UUIDs.

Anchors & Boundaries

Specify where in the line or string a match must occur.

Start of string / line

Matches the start of the string, or start of line in multiline mode.

^
End of string / line

Matches the end of the string, or end of line in multiline mode.

$
Word boundary

Matches the boundary between a word character and a non-word character.

\b
Non-word boundary

Matches any position that is NOT a word boundary.

\B

Character Classes

Match specific sets of characters.

Any character

Matches any single character except newline (unless 's' flag is set).

.
Digit

Matches any digit (equivalent to [0-9]).

\d
Non-digit

Matches any non-digit character (equivalent to [^0-9]).

\D
Word character

Matches alphanumeric characters plus underscore (equivalent to [a-zA-Z0-9_]).

\w
Non-word character

Matches any non-word character.

\W
Whitespace

Matches spaces, tabs, line breaks, and form feeds.

\s
Non-whitespace

Matches any character that is not whitespace.

\S
Character set

Matches any single character in the brackets (a, b, or c).

[abc]
Negated character set

Matches any single character NOT in the brackets.

[^abc]
Character range

Matches any lowercase letter from a to z.

[a-z]

Quantifiers

Control how many times an element must repeat.

Zero or more

Matches 0 or more times (greedy).

*
One or more

Matches 1 or more times (greedy).

+
Zero or one (optional)

Matches 0 or 1 time (greedy).

?
Exact count

Matches exactly 3 times.

{3}
Minimum count

Matches 3 or more times.

{3,}
Range count

Matches between 2 and 5 times.

{2,5}
Lazy quantifier

Matches the minimum possible characters instead of maximum.

*? / +?

Common Battle-Tested Patterns

Ready-to-use production regular expressions.

Email address

Standard RFC 5322 compliant email validator.

^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
URL (HTTP/HTTPS)

Matches valid web URLs with optional path and queries.

https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)
IPv4 Address

Matches valid IP addresses from 0.0.0.0 to 255.255.255.255.

^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$
UUID v4

Matches valid Version 4 UUID format.

^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$
Hex color code

Matches 3-digit or 6-digit hex color strings.

^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$
US Phone Number

Matches 10-digit phone numbers in various delimiters.

^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$

FAQ

Frequently Asked Questions

What is the difference between greedy and lazy quantifiers?

Greedy quantifiers (*, +) match as much text as possible. Appending a question mark (*?, +?) makes them lazy, matching the smallest substring that satisfies the pattern.

How do I test regular expressions in my browser?

You can test any regex in real-time using the MultiToolX Find and Replace Text tool with the Regex toggle enabled.

Explore More Technical Cheatsheets