Commonly used regex syntax such as character classes, anchors, quantifiers, and groups, summarized on one page. Based on JavaScript (ECMAScript) syntax.
Character Classes
.Any character except a line break
\dA digit [0-9]
\DA non-digit character
\wA word character [A-Za-z0-9_]
\WA non-word character
\sWhitespace (space, tab, line break)
\SA non-whitespace character
[abc]One of a, b, or c
[^abc]Any character except a, b, or c
[a-z]A range from a to z
Anchors · Boundaries
^Start of the string (or line)
$End of the string (or line)
\bA word boundary
\BA non-word-boundary position
(?=...)Positive lookahead
(?!...)Negative lookahead
(?<=...)Positive lookbehind
(?<!...)Negative lookbehind
Quantifiers
*Zero or more times
+One or more times
?Zero or one time
{n}Exactly n times
{n,}n or more times
{n,m}Between n and m times
*?Lazy (minimal) matching
Groups · Misc
(...)Capture group
(?:...)Non-capturing group
(?<name>...)Named capture group
a|ba or b (alternation)
\1Backreference to group 1
\.Escape a special character