Regex Cheatsheet
Quick reference for regular expression syntax, flags, and common patterns.
Anchors
^Start of string$End of string\bWord boundary\BNon-word boundaryCharacter Classes
.Any character except newline\dDigit [0-9]\DNon-digit\wWord char [a-zA-Z0-9_]\WNon-word char\sWhitespace\SNon-whitespaceQuantifiers
*0 or more+1 or more?0 or 1 (optional){n}Exactly n times{n,}n or more times{n,m}Between n and m*?Lazy (non-greedy)Groups
(abc)Capture group(?:abc)Non-capture group(?<name>)Named capture\1Backreference group 1(?=abc)Positive lookahead(?!abc)Negative lookaheadSets
[abc]Any of a, b, or c[^abc]Not a, b, or c[a-z]Range a through z[a-zA-Z]Any letterFlags
gGlobal (all matches)iCase-insensitivemMultiline (^ and $ per line)sDot matches newlineuUnicode modeCommon Patterns
\d{4}-\d{2}-\d{2}Date YYYY-MM-DD[\w.-]+@[\w.-]+\.\w+Email (simple)https?:\/\/\S+URL\b\d{1,3}(\.\d{1,3}){3}\bIPv4 addressFrequently Asked Questions
- The cheat sheet covers JavaScript/ECMAScript regex syntax, which is also largely compatible with Python, Java, and most modern languages.
Related Tools
CSS FormatterMinify or beautify CSS stylesheetsJS FormatterMinify or beautify JavaScript codeHTML FormatterBeautify or minify HTML markupHTML EscapeEscape special HTML characters to entitiesHTML StripperRemove all HTML tags to extract plain textHTML EntitiesSearchable reference for all HTML entity codesSQL FormatterBeautify and format SQL queriesXML FormatterFormat, validate, and minify XML documents instantly