Skip to content
browserutils

Regex Cheatsheet

Regex syntax quick reference

Regex Cheatsheet is a free online tool from BrowserUtils that regex syntax quick reference. It runs entirely in your browser — your data never leaves your device. No account required.

^
Start of string/line
^Hello
$
End of string/line
world$
\b
Word boundary
\bword\b
\B
Non-word boundary
\Bword\B
\A
Start of string (no multiline)
\AStart
\Z
End of string (no multiline)
End\Z
.
Any character except newline
a.b
\d
Digit [0-9]
\d{3}
\D
Non-digit [^0-9]
\D+
\w
Word character [a-zA-Z0-9_]
\w+
\W
Non-word character
\W
\s
Whitespace [ \t\n\r\f\v]
\s+
\S
Non-whitespace
\S+
[abc]
Character set (a, b, or c)
[aeiou]
[^abc]
Negated set (not a, b, or c)
[^0-9]
[a-z]
Character range
[a-zA-Z]
*
Zero or more
ab*c
+
One or more
ab+c
?
Zero or one (optional)
colou?r
{n}
Exactly n times
\d{4}
{n,}
n or more times
\w{3,}
{n,m}
Between n and m times
\d{2,4}
*?
Zero or more (lazy)
<.*?>
+?
One or more (lazy)
\w+?
??
Zero or one (lazy)
colou??r
*+
Zero or more (possessive)
\w*+
(abc)
Capturing group
(\d{3})-(\d{4})
(?:abc)
Non-capturing group
(?:https?://)
(?<name>abc)
Named capturing group
(?<year>\d{4})
\1
Backreference to group 1
(\w+)\s\1
a|b
Alternation (a or b)
cat|dog
(?=abc)
Positive lookahead
\d(?=px)
(?!abc)
Negative lookahead
\d(?!px)
(?<=abc)
Positive lookbehind
(?<=\$)\d+
(?<!abc)
Negative lookbehind
(?<!\$)\d+
g
Global - match all occurrences
/pattern/g
i
Case-insensitive matching
/hello/i
m
Multiline - ^ and $ match line boundaries
/^line/m
s
Dotall - . matches newlines
/a.b/s
u
Unicode - enable Unicode matching
/\p{L}/u
y
Sticky - match at lastIndex position
/pattern/y
Email
Basic email validation
[\w.-]+@[\w.-]+\.\w{2,}
URL
Basic URL matching
https?://[\w.-]+(?:/[\w.-]*)*
IPv4
IPv4 address
\b\d{1,3}(\.\d{1,3}){3}\b
Phone
US phone number
\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}
Date
Date (YYYY-MM-DD)
\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])
Hex Color
Hex color code
#(?:[0-9a-fA-F]{3}){1,2}\b

How to use Regex Cheatsheet

  1. 1 Paste or type your input into the editor above.
  2. 2 The tool processes your data instantly — right in your browser, with nothing sent to a server.
  3. 3 Copy the result with one click or continue editing your input.

About Regex Cheatsheet

Free online regex cheatsheet. Quick reference for regular expression syntax including anchors, quantifiers, character classes, groups, lookahead, and lookbehind. This tool runs entirely in your browser — your data is never sent to a server. Just paste your input, get instant results, and copy with one click. No sign-up or installation required.

Regex Cheatsheet specs

Runtime
100% client-side (browser)
Cost
Free — no account, no rate limits, no usage caps
Browser support
Chrome 90+, Firefox 88+, Safari 14+, Edge 90+
Part of
299 developer tools on BrowserUtils (100% client-side)

Questions

What is a regular expression?
A regular expression (regex) is a sequence of characters that defines a search pattern. It is used for pattern matching in strings, commonly for validation, search-and-replace, and text parsing.
What is the difference between greedy and lazy quantifiers?
Greedy quantifiers (*, +, ?) match as much text as possible, while lazy quantifiers (*?, +?, ??) match as little as possible. For example, in the string "<b>bold</b>", the pattern <.*> matches the entire string (greedy) while <.*?> matches just <b> (lazy).
How do I write a regex to validate an email address?
A basic pattern is ^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,}$. However, fully RFC-compliant email validation with regex is extremely complex. For production use, combine a simple regex with server-side verification.
Is regex syntax the same across all programming languages?
The core syntax (character classes, quantifiers, anchors) is similar across most languages, but advanced features differ. For example, lookbehind support, named groups, and Unicode property escapes vary between JavaScript, Python, PCRE, and others.
What are lookahead and lookbehind in regex?
Lookahead (?=...) and lookbehind (?<=...) are zero-width assertions that match a position based on what comes after or before it, without including those characters in the match. They are useful for conditional matching without consuming text.
Embed this tool

Copy this code to embed the tool on your website. Adjust the height to fit your layout.

<iframe src="https://www.browserutils.dev/embed/regex-cheatsheet" width="100%" height="500" frameborder="0" title="Regex Cheatsheet"></iframe>

Related tools

More Developer Reference

View all Developer Reference tools