Quantifiers
A quantifier is used to define how many times a preceding character or group is repeated. Three examples of quantifiers have already been introduced: *
, +
, and ?
. The quantifiers are as follows:
Character | Description | Example |
* | The preceding character repeated zero or more times | 'abc' -match 'a*' # True'abc' -match '.*' # True |
+ | The preceding character repeated one or more times | 'abc' -match 'a+' # True'bcd' -match 'a+' # False'abc' -match '.+' # True'' -match '.+' # False |
? | Optional character | 'abc' -match 'ab?c' # True'ac' -match 'ab?c' # True'ab' -match 'ab?c' # False |
{exactly} | A fixed number of characters | 'abbbc' -match 'ab{3}c' # True'abc' -match 'ab{3}c' # False |
{min,max} | Several characters within a range | 'abc' -match &apos... |