Regex Cheat Sheet — Guide
A complete regex cheat sheet — common regular expression syntax, quantifiers, flags and character classes with examples.
What it is and when to use it
Regex syntax is easy to forget precisely because it is dense: character classes, quantifiers, anchors and groups are all written in punctuation. This cheat sheet collects the constructs you actually reach for — ready-made patterns for emails, URLs and dates, the common character classes, and lookahead examples — so you copy a working starting point instead of rebuilding it from memory.
A cheat sheet of common regular expressions for when you have forgotten the syntax.
How to use it
- Find the syntax you need by category
- Copy the fragment
- Verify it in the Regex Tester
Things that trip people up
- Syntax is JavaScript-flavoured (the \d, \w and [...] classes, and groups). Features such as lookbehind and named capture are engine-specific — test in the Regex Tester before assuming another language behaves the same
- This is a construct reference, not a full grammar: less common features such as atomic groups or possessive quantifiers are intentionally out of scope
Questions people ask
- Are these patterns production-ready?
- They are solid starting points for common cases. The classic example: fully RFC-compliant email validation is practically impossible in pure regex — the patterns here cover the pragmatic 99%, not the adversarial 1%.
- Will these patterns work in every language?
- The core syntax (classes, quantifiers, groups, anchors) is nearly universal. Advanced features like lookbehind or named groups vary by engine — verify JavaScript behavior in the Regex Tester.
- How do I adapt a pattern to my case?
- Copy it into the Regex Tester, paste a sample of your real text, then tighten the pattern until only the parts you want are highlighted.
Next steps
Open the Regex Cheat Sheet tool
- Regex Tester
- Git cheatsheet
- Random port generator
- Crontab Generator
- JSON Formatter & Validator
- JSON minify
Spotted something wrong on this page? Tell us via Contact Us