Table D-1 Pattern Matching Metacharacters
Pattern Matching Metacharacters
|
Description
|
Example
|
*
|
Matches zero or more instances of the preceding character or character pattern.
|
The pattern `goo*' matches `my godness', `my goodness', and `my gooodness', but not `my gdness'.
|
+
|
Matches one or more instances of the preceding character or character pattern.
|
The pattern `goo+' matches `my goodness' and `my gooodness', but not `my godness'.
|
?
|
Matches zero or one instance of the preceding character or character pattern.
|
The pattern `goo?' matches `my godness' and `my goodness', but not `my gooodness' or `my gdness'.
|
$
|
Matches the end of the string.
|
The pattern `end$' matches `the end', but not `the ending'.
|
^
|
Matches the beginning of the string.
|
The pattern `^severity' matches `severity level 5', but not `The severity is 5'.
|
.
|
Matches any single character.
|
The pattern `b.at' matches `baat', `bBat', and `b4at', but not `bat' or `bB4at'.
|
[abcd]
|
Matches any characters in the square brackets or in the range of characters separated by a hyphen (-), such as [0-9].
|
^[A-Za-z]+$ matches any string that contains only upper or lower case letter characters.
|
[^abcd]
|
Matches any character except those in the square brackets or in the range of characters separated by a hyphen (-), such as [0-9].
|
[^0-9] matches any string that does not contain any numeric characters.
|
()
|
Indicates that the characters within the parentheses should be treated as a character pattern.
|
A(boo)+Z matches `AbooZ', `AboobooZ', and `AbooboobooZ', but not `AboZ' or `AboooZ'.
|
|
|
Matches one of the characters or character patterns on either side of the vertical bar.
|
A(B|C)D matches `ABD' and `ACD', but not `AD', `ABCD', `ABBD', or `ACCD'.
|
\
|
The backslash escape character indicates that the metacharacter following should be treated as a regular character. The metacharacters in this table require a backslash before them if they appear in a regular expression.
|
To match an opening square bracket, followed by any digits or spaces, followed by a closed bracket, use the regular expression \[[0-9 ]*\].
|