Regular Expression Quantifiers
Regular Expression Quantifiers
Regular Expression Quantifiers
*
0 or more
+
1 or more
?
0 or 1
{2}
Exactly 2
{2, 5}
Between 2 and 5
{2,}
2 or more
Regular Expression Special Characters
(,5}
Up to 5
\n
Newline
Default is greedy. Append ? for reluctant.
\r
Carriage return
\t
Tab
\YYY
Octal character YYY
\xYY
Hexadecimal
character
YY Replacement
Regular
Expression
\g<0>
Insert entire match
\g<Y>
Insert match Y (name or number)
\YExpression Basics
Insert group numbered Y
Regular
.
a
ab
a|b
a*
i
\
m
s
x
L
[ab-d]
u
[^ab-d]
(?iLmsux)
[\b]
\d
\D
\s
\S
\w
\W
(...)
(?P<Y>...)
(?:...)
\Y
(?P=Y)
(?#...)