Metacharacter |
Description |
Example |
. | A period matches any single character. | A.C matches ABC , AbC , AxC , and A%C |
? | A question mark matches either zero or one occurrences of the previous regular expression. | A?C matches AAC (one occurrence) and AC (zero occurrences), but not AAAC (two occurrences) |
* | An asterisk matches zero or more occurrences of the previous regular expression. | A* matches A (one occurrence), AA (two occurrences), AAAAAA (six occurrences) and "" (zero occurrences) |
+ | A plus sign matches one or more occurrences of the previous regular expression. | A+ matches A (one occurrence), AA (two occurrences), AAAAAA (six occurrences) but not "" (zero occurrences) |
[ | An open square bracket introduces a character range, which is shorthand for any of a certain set of characters. Close the range with a closed square bracket. Any metacharacter that appears inside a range loses its special meaning. To include a closed square bracket (] ) in the range, place it at the beginning of the range. | A[xyz]C matches AxC , AyC , and AzC A[.]C matches only A.C A[[]C matches only A[C |
( | An open parenthesis introduces an option group. Separate each option with a vertical bar (| ) and end the option group with a closed parenthesis. Any metacharacter that appears inside a range loses its special meaning. | A(foo|b)C matches AfooC or AbC |
^ | A caret means the regular expression must match at the beginning of a line. | ^ABC will match ABC only if the "A" is the first character on the line |
$ | A dollar sign means the regular expression must match at the end of a line. | ABC$ will match ABC only if the "C" is the last character on the line |
\ | A slash in front of any metacharacter removes that metacharacter's special meaning. | A\.C will match only A.C |
! | An exclamation point at the start of a condition negates the condition's meaning. | !A\.C will match everything but A.C |