Regex Cheatsheet
Search a categorized reference of regular expression syntax - anchors, character classes, quantifiers, groups, and common patterns.
Anchors
^
Start of string (or line, with the m flag)
$
End of string (or line, with the m flag)
\b
Word boundary
\B
Not a word boundary
Character Classes
.
Any character except newline
\d
Any digit (0-9)
\D
Any non-digit
\w
Any word character (letters, digits, underscore)
\W
Any non-word character
\s
Any whitespace character
\S
Any non-whitespace character
[abc]
Any one of a, b, or c
[^abc]
Any character except a, b, or c
[a-z]
Any character in the range a to z
Quantifiers
*
Zero or more of the preceding token
+
One or more of the preceding token
?
Zero or one of the preceding token
{n}
Exactly n of the preceding token
{n,}
n or more of the preceding token
{n,m}
Between n and m of the preceding token
*?
Zero or more, non-greedy (as few as possible)
+?
One or more, non-greedy (as few as possible)
Groups
(abc)
Capturing group
(?:abc)
Non-capturing group
(?<name>abc)
Named capturing group
(a|b)
Match either a or b
Lookaround
(?=abc)
Positive lookahead - followed by abc
(?!abc)
Negative lookahead - not followed by abc
(?<=abc)
Positive lookbehind - preceded by abc
(?<!abc)
Negative lookbehind - not preceded by abc
Flags
g
Global - find all matches, not just the first
i
Case-insensitive matching
m
Multiline - ^ and $ match line boundaries
s
Dotall - . also matches newline characters
u
Unicode - enables full Unicode matching
Common Patterns
^\d{3}-\d{4}$
A simple phone number format like 555-1234
^[\w.+-]+@[\w-]+\.[\w.-]+$
A basic email address pattern
^https?:\/\/\S+$
A basic URL starting with http or https
^\d{4}-\d{2}-\d{2}$
A date in YYYY-MM-DD format
Recommended Settings
Pro Tips
- •Non-greedy quantifiers (*? and +?) match as little as possible, which is often what you actually want when matching content between delimiters
- •Named capture groups (?<name>...) make patterns with multiple groups far easier to read and reference in code than numbered groups
- •Lookahead and lookbehind let you match a position based on surrounding text without including that text in the match itself
- •The common patterns section gives you a starting point for typical validation needs - always test thoroughly against your actual expected input
Most Popular
Most developers look up character classes and quantifiers most often when building or debugging a pattern
When to Use This Tool
Quickly find the exact syntax for a token or flag you don't use often.
Start from a common pattern for emails, URLs, or dates instead of writing one from scratch.
Browse categorized syntax to build a solid mental model of regex building blocks.
Look up unfamiliar syntax encountered in someone else's regular expression.
How It Works
Search a curated reference of regular expression syntax grouped by category
Filter results instantly as you type, matching against the token, description, and category
Copy any pattern or token directly to your clipboard for use in your code
100% Private
Files never leave your device. All processing happens locally in your browser.
Lightning Fast
Powered by Client-side static reference lookup for optimal performance on modern browsers.
Open Source
Built with verified, open-source libraries. Fully transparent.
Frequently Asked Questions
What's the difference between greedy and non-greedy quantifiers?
A greedy quantifier like * matches as much text as possible, while its non-greedy version *? matches as little as possible before backtracking to find a valid overall match.
When should I use lookahead or lookbehind?
Use them when you need to match a position based on what comes before or after it, without including that surrounding text as part of the actual match - useful for validating a password's requirements without capturing each part separately.
Are these patterns production-ready?
The common patterns are simplified starting points for learning and quick use - production validation (especially for emails) often needs more thorough patterns or dedicated validation libraries.
Is my search sent anywhere?
No. Searching happens entirely locally against a static list in your browser.