📖

Regex Cheatsheet — Regular Expression Reference

Complete regular expression reference with examples for all syntax patterns.

Regex Cheatsheet

Anchors

^Start of string
$End of string
\bWord boundary
\BNot word boundary

Quantifiers

*0 or more
+1 or more
?0 or 1
{n}Exactly n
{n,}n or more
{n,m}Between n and m

Character Classes

.Any char except newline
\dDigit [0-9]
\DNon-digit
\wWord char [a-zA-Z0-9_]
\WNon-word
\sWhitespace
\SNon-whitespace

Groups

(abc)Capture group
(?:abc)Non-capturing group
(?=abc)Lookahead
(?!abc)Negative lookahead
(?<=abc)Lookbehind
(?<!abc)Negative lookbehind

Flags

gGlobal — find all matches
iCase-insensitive
mMultiline — ^ and $ match line start/end
sDotall — . matches newline
uUnicode mode