Quantifiers
You can specify quantities of character sets, grouped characters, or individual characters. The quantifiers *
, +
, ? , and { }
act on the preceding set, group, or individual character.
Character | Purpose | Example | Match |
---|---|---|---|
* | Specifies 0 or more consecutive occurrences | ab*c | ac , abc , abbbbc |
+ | Specifies 1 or more consecutive occurrences | ab+c | abc , abbbbc |
? | Specifies 0 or 1 occurrence | colou?r (wo)?man | color or colour woman or man |
{ x } | Exactly <x> occurrences | ab { 4 } c | abbbbc |
{ x,y } | At least <x> , no more than <y> occurrences | ab { 2,4 } c | abbc , abbbc , abbbbc |
{ x, } | At least <x> occurrences | ab { 2, } c | abbc , abbbc |
{ ,x } | No more than <x> occurrences | ab { ,2 } c | ac , abc , or abbc |