You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Regex Cheatsheet: Patterns, Anchors & Common Examples
A regular-expression reference that works across most engines (PCRE, JavaScript, Python, Java, Go). Character classes, quantifiers, groups, lookarounds, plus copy-paste patterns for the things people actually match: email, URL, dates, IPs.
Character classes
Pattern
Matches
.
any character except newline
\d
digit [0-9]
\D
non-digit
\w
word char [A-Za-z0-9_]
\W
non-word char
\s
whitespace (space, tab, newline)
\S
non-whitespace
[abc]
a, b, or c
[^abc]
NOT a, b, or c
[a-z]
range a to z
[a-zA-Z0-9]
alphanumeric
Anchors & boundaries
Pattern
Matches
^
start of string/line
$
end of string/line
\b
word boundary
\B
non-word boundary
\A\Z
start / end of whole string (PCRE/Python)
Quantifiers
Pattern
Means
*
0 or more
+
1 or more
?
0 or 1 (optional)
{3}
exactly 3
{2,5}
between 2 and 5
{2,}
2 or more
*?+?
lazy (as few as possible)
Groups & alternation
(abc) capturing group
(?:abc) non-capturing group
(?<name>abc) named group
a|b a OR b
\1 backreference to group 1