💻 Development
Regex Cheatsheet
Regular expression syntax reference
Regular expression syntax cheatsheet. Quick reference for regex patterns, quantifiers, character classes, and anchors. Free regex guide.
Character Classes
.Any character except newline\dDigit (0-9)\DNot a digit\wWord character (a-z, A-Z, 0-9, _)\WNot a word character\sWhitespace (space, tab, newline)\SNot whitespace[abc]Any of a, b, or c[^abc]Not a, b, or c[a-z]Character range a-z[A-Za-z]Any letter[0-9]Any digitAnchors
^Start of string (or line with m flag)$End of string (or line with m flag)\bWord boundary\BNot a word boundary(?=...)Positive lookahead(?!...)Negative lookahead(?<=...)Positive lookbehind(?<!...)Negative lookbehindQuantifiers
*Zero or more+One or more?Zero or one (optional){n}Exactly n times{n,}n or more times{n,m}Between n and m times*?Zero or more (lazy)+?One or more (lazy)??Zero or one (lazy)Groups & References
(...)Capturing group(?:...)Non-capturing group(?<name>...)Named capturing group\1Backreference to group 1\k<name>Backreference to named group(a|b)Match a or bEscape Sequences
\nNewline\rCarriage return\tTab\0Null character\.Escaped special character (literal dot)\\BackslashFlags
gGlobal - find all matchesiCase insensitivemMultiline - ^ and $ match line boundariessDotall - . matches newlinesuUnicode supportySticky - match at lastIndex positionCommon Patterns
^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,}$Email address^https?://[\w.-]+(?:/[\w./-]*)?$URL^\d{3}-\d{3}-\d{4}$Phone number (US)^\d{5}(-\d{4})?$ZIP code (US)^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$Hex color^\d{4}-\d{2}-\d{2}$Date (YYYY-MM-DD)^(?:\d{1,3}\.){3}\d{1,3}$IPv4 address (simple)^[a-z0-9-]+$Slug (lowercase, numbers, dashes)