This chapter shows you how to use a wildcard pattern in a text field to match a number of elements instead of specifying each element by name. (Smarts programs, such as the Global Console, enable you to specify wildcard patterns in text fields.)
Types of wildcard patterns
A wildcard pattern is a series of characters that are matched against incoming character strings. You can use these patterns when you define pattern matching criteria.
Matching is done strictly from left to right, one character or basic wildcard pattern at a time. Basic wildcard patterns are defined in the following table. Characters that are not part of match constructs match themselves. The pattern and the incoming string must match completely. For example, the pattern abcd does not match the input abcde or abc.
A compound wildcard pattern consists of one or more basic wildcard patterns separated by ampersand (&) or tilde (~) characters. A compound wildcard pattern is matched by attempting to match each of its component basic wildcard patterns against the entire input string. For compound wildcard patterns, see table, Compound wildcard patterns.
|?||Matches any single character.
For example, server?.example.com matches server3.example.com and
serverB.example.com, but not server10.example.com.
|*||Matches an arbitrary string of characters. The string can be empty.
For example, server*.example.com matches server-ny.example.com and server.example.com (an empty match).
|[set]||Matches any single character that appears within [set]; or, if the first character of [set] is (^), any single character that is not in the set. A hyphen (-) within [set] indicates a range, so that [a-d] is equivalent to [abcd]. The character before the hyphen (-) must precede the character after it or the range will be empty. The character (^) in any position except the first, or a hyphen (-) at the first or last position, has no special meaning.
For example, server[789-].example.com matches server7.example.com through server9.example.com, but not server6.example.com. It also matches server-.example.com.
For example, server[^12].example.com does not match server1.example.com or server2.example.com, but will match server8.example.com.
|<n1-n2>||Matches numbers in a given range. Both n1 and n2 must be strings of digits, which represent non-negative integer values. The matching characters are a non-empty string of digits whose value, as a non-negative integer, is greater than or equal to n1 and less than or equal to n2. If either end of the range is omitted, no limitation is placed on the accepted number.
For example, 98.49.<1-100>.10 matches a range of IP addresses from 18.104.22.168 through 22.214.171.124.
Example of an omitted high end of the range: <50-> matches any string of digits with a value greater than or equal to 50.
Example of an omitted low end of the range: <-150> matches any value between zero and 150. For a more subtle example: The pattern <1-10>* matches 1, 2, up through 10, with * matching no characters. Similarly, it matches strings like 9x, with * matching the trailing x.
However, it does not match 11, because <1-10> always extracts the longest possible string of digits (11) and then matches only if the number it represents is in range.
||||Matches alternatives. For example,”ab|bc|cd” without spaces matches exactly the three following strings: “ab”, “bc”, and “cd”. A | as the first or last character of a pattern accepts an empty string as a match.
Example with spaces “ab | bc” matches the strings “ab” and “ bc”.
|\||Removes the special status, if any, of the following character. Backslash (\) has no special meaning within a set ([set]) or range (<n1-n2>) construct.|
Special characters for compound wildcard patterns are summarized in the following Compound wildcard patterns
|&||“And Also” for a compound wildcard pattern. If a component basic wildcard pattern is preceded by & (or is the first basic wildcard pattern in the compound wildcard pattern), it must successfully match.
Example: *NY*&*Router* matches all strings which contain NY and also contain Router.
Example: <1-100>&* matches even numbers between 1 and 100 inclusive. The <1-100> component only passes numbers in the correct range and the * component only passes numbers that end in an even digit.
Example: *A*|*B*&*C* matches strings that contain either an A or a B, and also contain a C.
|~||“Except” for a compound wildcard pattern (opposite function of &).If a component basic wildcard pattern is preceded by ~, it must not match.
Example: 10.20.30.*~10.20.30.50 matches all devices on network 10.20.30 except 10.20.30.50.
Example: *Router*~*Cisco*&*10.20.30.*~10.20.30.<10-20>* matches a Router, except a Cisco router, with an address on network 10.20.30, except not 10.20.30.10 through 10.20.30.20.