Repetition
Search expressions can be expanded using the repetition characters ?, + and *. These characters can appear after the specification to extend its match. A repetition character cannot appear as the first character of a regular expression.
• ?
Matches zero or one occurrence of the character or character class that precedes it. For example, s[aeiou]?n matched “sin”, “son”, “sun”, and “sn” but not “seen” or “soon”.
• +
Matches one or more occurrences of a character or character class that precedes it. For example, s[aeiou]+n matches “sin”, “son”, “sun”, and also “seen” and “soon”.
• *
Matches zero or more occurrences of a character or character class that precedes it. For example, 21* can match “2”, “21”, and “2111”.
The repetition characters can also be applied to groups as explained in the following sections.