Repetition
A quantifier is used to repeat an element; three of the quantifiers have already been introduced: *
, +
, and ?
. The quantifiers are as follows:
Description | Character | Example |
The preceding character repeated zero or more times |
|
|
The preceding character repeated one or more times |
|
|
Optional character |
|
|
A fixed number of characters |
|
|
A number of characters within a range |
|
|
No less than a number of characters |
|
|
Each *
, +
, and ?
can be described using a curly brace notation:
*
is the same as{0,}
+
is the same as{1,}
?
is the same as{0,1}
It is extremely uncommon to find examples where the functionality of special characters is replaced with curly braces. It is equally uncommon to find examples where the quantifier {1}
is used as it adds unnecessary...