REGEX Cheat Sheet

Basic REGEX Wild Cards

REGEX

June 2024

REGEX Cheat Sheet
Character ClassesDescription
[abc]a single character of a, b or c
[^abc]a character except a, b or c
[a-z]a character in the range a-z
[^a-z]a character not in range a-z
[a-zA-Z]a character in the range of a-z or A-Z
QuantifiersDescription
a?zero or one of a
a*zero or more of a
a+one or more of a
a{3}Exactly 3 of a
a{3,}3 or more of a
a{3,6}Between 3 and 6 of a
a{3,6}Between 3 and 6 of a
a*Greedy Quantifier
a*?Lazy Quantifier
Meta SequenceDescription
. Any single character other than newline (or including line terminators with the /s flag)
a|balternate - match a or b
\sMatches any space, tab or newline character
\SMatches anything other than a space, tab or newline
\dMatches any decimal digit. Equivalent to [0-9]
\DMatches anything other than a decimal/digit
\wMatches any letter, digit or underscore. Equivalent to [a-zA-Z0-9_]
\WMatches anything other than a letter, digit or underscore. Equivalent to [^a-zA-Z0-9_]
AnchorsDescription
\ba word boundary
\Bnon word boundary
^start of a string
$end of a string