Regex Cheatsheet
TextQuick reference for JS regex syntax, character classes, anchors and quantifiers, a handy cheat sheet for writing and debugging match patterns.
.Any char except newline\dDigit 0-9\DNon-digit\wWord char\WNon-word char\sWhitespace\SNon-whitespace[abc]Match a, b, or c[^abc]Not a, b, or c[a-z]a through z range^Start of string$End of string\bWord boundary\BNon word boundary*Zero or more+One or more?Zero or one{n}Exactly n times{n,}n or more{n,m}Between n and m times*?Lazy zero or more+?Lazy one or more(abc)Capturing group(?:abc)Non-capturing group(?<name>abc)Named group(?=abc)Positive lookahead(?!abc)Negative lookahead(?<=abc)Positive lookbehind(?<!abc)Negative lookbehind\1Backreference to group 1gGlobaliCase insensitivemMultilinesDot matches newlineuUnicode modeySticky (y flag)^\d{4}-\d{2}-\d{2}$ISO date^[\w.+-]+@[\w-]+\.[\w.-]+$Simple email^https?:\/\/\S+$HTTP URL^\d{3}-\d{2}-\d{4}$US SSN^#?([a-f\d]{6}|[a-f\d]{3})$Hex color^\+?[1-9]\d{1,14}$E.164 phoneAbout Regex Cheatsheet
Writing regex always means recalling what \d, \w, quantifiers, and zero-width assertions mean, and flipping through docs is slow. This tool is a structured regular-expression cheat sheet that groups common syntax — character classes, quantifiers, anchors, groups, and assertions — by topic, with explanations and examples. Everything loads locally with the page and needs no network lookup, so you can reference it while coding and assemble the right pattern fast. Tip: Bookmark this tool for quick access whenever you need text processing. All processing happens locally in your browser — no data upload, so feel free to paste private content.
How to Use
- Open the Regex Cheatsheet tool page
- Enter or paste your data into the input area
- View the real-time results and use the copy button to get the output
Use Cases
- Recall syntax — Instantly look up .*? vs .+? when you forget how to write a non-greedy match.
- Assertion lookup — Check lookahead and lookbehind syntax to match only in a specific context.
- Class reference — Look up \d, \s, \b and avoid misusing \b inside a character set.
- Interview prep — Systematically review regex syntax for written tests and technical interviews.
- Teaching aid — Use the cheat sheet as a shared reference when explaining regex to newcomers.
- Pattern debugging — Cross-reference a regex pattern's components against the cheat sheet to find the exact syntax error.
- Migration reference — Update old PCRE patterns to ECMAScript-compatible syntax by checking the supported features per engine.
FAQ
Which regex flavor does the sheet target?
It centers on the most common syntax, close to JavaScript (ECMAScript); most rules also apply to PCRE and Python, with minor engine-specific differences.
Is \b consistent across languages?
The basic meaning of the word boundary \b is the same, but boundary detection for Unicode characters like CJK can differ between engines, so test it.
Can I test my regex here?
This page is a syntax reference; to verify matches as you type, use one of our regex tester tools for live debugging.
What is the difference between greedy and lazy?
A greedy quantifier like * matches as much as possible, while a lazy one like *? matches as little as possible; lazy is common for paired structures like HTML tags to avoid overshooting.
Why do I need two backslashes in a string?
In most languages a backslash must be escaped in string literals, so regex \d is often written as two backslashes plus d in code — mind the difference.
Any browser compatibility requirements?
This tool works in all modern browsers (Chrome, Firefox, Edge, Safari). No plugins or extensions required.
Can I use it offline?
After initial load, most features work offline. The core logic runs entirely in your browser with no network dependency.
Comments
Comments are stored locally in your browser. Configure Giscus for cloud-based comments.