The three utilities egrep, grep when run with the E option (similar to egrep), and gawk provide all the special characters that are included in ordinary regular expressions, except for \ ( and \ ), as well as several others. The vim editor includes the additional characters as well as \ ( and \ ). Patterns using the extended set of special characters are called full regular expressions or extended regular expressions.
Two of the additional special characters are the plus sign (+) and the question mark (?). They are similar to *, which matches zero or more occurrences of the previous character. The plus sign matches one or more occurrences of the previous character, whereas the question mark matches zero or one occurrence. You can use any one of the special characters *, +, and ? following parentheses, causing the special character to apply to the string surrounded by the parentheses. Unlike the parentheses in bracketed regular expressions, these parentheses are not quoted (Table A-7).
Table A-7. Extended regular expressions
a followed by one or more b's followed by a c
a followed by zero or one b followed by c
One or more occurrences of the string ab followed by c
Zero or one occurrence of the string ab followed by c
In full regular expressions, the vertical bar ( | ) special character is a Boolean OR operator. Within vim, you must quote the vertical bar by preceding it with a backslash to make it special (\|). A vertical bar between two regular expressions causes a match with strings that match the first expression, the second expression, or both. You can use the vertical bar with parentheses to separate from the rest of the regular expression the two expressions that are being ORed (Table A-8).
Table A-8. Full regular expressions
Either ab or ac
ab, ac, abac (abac is two matches of the regular expression)
Lines that begin with Exit or Quit
D. Jones or N. Jones
P.D. Jones, N. Jones