Regex Patterns
Common regular expression patterns and syntax
Programming
Character Classes
.Any character except newline
\dDigit (0-9)
\DNon-digit
\wWord character (a-z, A-Z, 0-9, _)
\WNon-word character
\sWhitespace
\SNon-whitespace
Anchors
^Start of string/line
$End of string/line
\bWord boundary
\BNon-word boundary
Quantifiers
*0 or more
+1 or more
?0 or 1
{n}Exactly n times
{n,}n or more times
{n,m}Between n and m times
Groups & Lookaround
(abc)Capturing group
(?:abc)Non-capturing group
(?=abc)Positive lookahead
(?!abc)Negative lookahead
(?<=abc)Positive lookbehind
(?<!abc)Negative lookbehind
Common Patterns
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$^https?://[\w.-]+(?:/[\w.-]*)*$URL
^\d{3}-\d{3}-\d{4}$Phone (US)
^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$Hex Color