Regex Cheatsheet
Comprehensive regular expression cheatsheet with character classes, anchors, quantifiers, groups, and common patterns. Free, private, browser-based.
Local processingCharacter Classes
. | Any character except newline | |
\d | Digit [0-9] | |
\D | Non-digit | |
\w | Word char [a-zA-Z0-9_] | |
\W | Non-word char | |
\s | Whitespace | |
\S | Non-whitespace | |
[abc] | Any of a, b, c | |
[^abc] | Not a, b, or c | |
[a-z] | Range a to z | |
[a-zA-Z0-9] | Alphanumeric |
Anchors
^ | Start of string | |
$ | End of string | |
\b | Word boundary | |
\B | Non-word boundary | |
^$ | Empty string |
Quantifiers
* | 0 or more | |
+ | 1 or more | |
? | 0 or 1 (optional) | |
{n} | Exactly n | |
{n,} | n or more | |
{n,m} | Between n and m | |
*? | Lazy 0+ (non-greedy) | |
+? | Lazy 1+ (non-greedy) |
Groups & Alternation
(abc) | Capture group | |
(?:abc) | Non-capturing group | |
(?<name>abc) | Named group | |
\1 | Backreference to group 1 | |
\k<name> | Backreference to named group | |
a|b | Alternation (a or b) |
Lookarounds
(?=abc) | Lookahead: followed by abc | |
(?!abc) | Negative lookahead | |
(?<=abc) | Lookbehind: preceded by abc | |
(?<!abc) | Negative lookbehind |
Unicode & Flags
/i | Case-insensitive | |
/g | Global (all matches) | |
/m | Multiline (^/$ match line bounds) | |
/s | Dotall (. matches newline) | |
/u | Unicode mode | |
/y | Sticky (match at lastIndex) | |
\p{L} | Unicode letter | |
\p{N} | Unicode number | |
\p{Emoji} | Unicode emoji |
Common Patterns
^[\w.+-]+@[\w-]+\.[\w.-]+$ | Email (simple) | |
^https?://[\w.-]+\.[a-z]{2,} | URL (simple) | |
^\d{4}-\d{2}-\d{2}$ | Date YYYY-MM-DD | |
^\d{3}-\d{2}-\d{4}$ | SSN format | |
^(\+\d{1,3})?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$ | Phone number | |
^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$ | Hex color | |
^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$ | IPv4 address | |
^[a-f0-9]{32}$ | MD5 hash | |
^[a-f0-9]{40}$ | SHA-1 hash | |
^[a-f0-9]{64}$ | SHA-256 hash |
What is Regex Cheatsheet?
A regular expression (regex) is a pattern that describes a set of strings. This cheatsheet covers the JavaScript regex syntax: character classes, anchors, quantifiers, groups, lookarounds, and common practical patterns.
How It Works
The tool displays a searchable, categorized reference of regex syntax with descriptions and examples. A filter input narrows results by syntax or description.
Common Use Cases
- Quick regex syntax lookup
- Learning regular expressions
- Finding common regex patterns for validation
Technical Details
Static reference data for JavaScript regex flavor (ES2024). Includes PCRE-compatible features supported in JS: lookbehind, named groups, unicode property escapes (\p{...}), and the /v flag for set operations.
How to Use
- Browse syntax by category
- Use the filter box to search
- Copy any pattern with the copy button
Privacy
All processing happens in your browser. Your data is never uploaded to any server.
FAQ
Which regex flavor is covered?
JavaScript (ES2024) regex flavor, including lookbehind, named groups, unicode property escapes, and the /v flag.
Can I search for specific patterns?
Yes. Use the filter box to search across all syntax entries and common patterns.