Request a tool
DEVELOPER TOOLS · FREE ONLINE TOOL

Regex Cheat Sheet

Regular expression syntax, character classes, and ready-made patterns with plain-English explanationsFree regex cheat sheet: character classes, quantifiers, anchors, groups, flags, and copy-ready patterns for email, URL, phone, and dates. Searchable and printable.

✓ Free to use✓ No sign-up✓ Ready in your browser
// REGEX CHEAT SHEET · GET STARTED

Use Regex Cheat Sheet

Regular expression syntax, character classes, and ready-made patterns with plain-English explanations

44 of 44 entries shown. Click Copy on any snippet.

Character Classes

Any character · Any single character except a newline
.
Digit · 0-9 (use \D for non-digit)
\d
Word character · Letters, digits, underscore (\W is the opposite)
\w
Whitespace · Space, tab, newline (\S is non-whitespace)
\s
Custom set · Any one of these characters
[aeiou]
Negated set · Any character except digits
[^0-9]
Range · Any ASCII letter
[a-zA-Z]
Literal dot · A real dot, not the wildcard
\.

Quantifiers

Zero or more · Greedy: as many a's as possible, including none
a*
One or more · At least one a
a+
Optional · The u may or may not appear
colou?r
Exact count · Exactly 4 digits
\d{4}
Range count · Between 2 and 4 digits
\d{2,4}
Open range · 3 or more digits
\d{3,}
Lazy star · As few a's as possible (non-greedy)
a*?
Lazy plus · Shortest match inside angle brackets
<.*?>

Anchors and Boundaries

Start of string · Matches only at the very start
^hello
End of string · Matches only at the very end
world$
Word boundary · Whole word cat, not scatter
\bcat\b
Multiline start · With the m flag: start of each line
^\d+

Groups and Capturing

Capture group · Two groups you can reference as $1 and $2
(\d+)-(\d+)
Non-capturing · Group without capturing
(?:https?://)
Named group · Reference later as $&lt;year&gt;
(?<year>\d{4})
Alternation · Either cat or dog
cat|dog
Backreference · A repeated word like 'the the'
(\w+) \1

Flags

Case insensitive · Matches ABC, Abc, and so on
/abc/i
Global · Find all matches, not just the first
/\d+/g
Multiline · ^ and $ work per line
/^\w+/gm
Dot all · Dot also matches newlines
/a.*b/s
Unicode · Any Unicode letter
/\p{L}/u

Common Patterns

Email (practical) · Covers 99 percent of real addresses
[\w.-]+@[\w-]+\.[a-z]{2,}
URL · http or https links
https?://[^\s/$.?#].[^\s]*
Phone (loose) · International-ish phone numbers
\+?[\d\s().-]{7,}
Date YYYY-MM-DD · ISO-style dates
\d{4}-\d{2}-\d{2}
Time HH:MM · 24-hour clock times
\d{2}:\d{2}
Hex color · Six-digit hex like #ff8800
#[0-9a-fA-F]{6}\b
IPv4 · Rough IPv4 match (validates format, not range)
\b(?:\d{1,3}\.){3}\d{1,3}\b
Slug · URL-friendly lowercase slugs
^[a-z0-9]+(?:-[a-z0-9]+)*$
No HTML tags · Matches a single tag
<[^>]+>

Escapes

Escape special · Prefix any of these with a backslash to match literally
\^$.*+?()[]{}|
Tab / newline · Common whitespace escapes
\t \n \r

Lookarounds

Positive lookahead · Digits only when followed by px
\d+(?=px)
Negative lookahead · Digits not followed by px
\d+(?!px)
Positive lookbehind · Digits right after a dollar sign
(?<=\$)\d+
// REGEX CHEAT SHEET · HOW IT WORKS

How to use the Regex Cheat Sheet

01

Search

Type in the search box to filter patterns.

02

Copy

Click Copy on any pattern to grab it.

03

Print

Print the page for a desk reference.

// REGEX CHEAT SHEET · ABOUT THIS TOOL

About the Regex Cheat Sheet

Regular expressions are a compact language for matching text: character classes like \d, quantifiers like +, anchors like ^, groups for capturing, and flags that change matching behavior. This cheat sheet collects the syntax you actually use, each with a plain-English explanation.

It also includes battle-tested patterns for email, URLs, phone numbers, dates, hex colors, and slugs. Search to find what you need, copy with one click, and print it for your desk.

// REGEX CHEAT SHEET · COMMON QUESTIONS

Regex Cheat Sheet FAQs

* means zero or more (the pattern may be absent entirely), while + means one or more (at least one occurrence is required). For example, colou?r uses ? for zero or one.