1-16
Catalyst 6500 Series Switch Command Reference—Release8.4
OL-6244-01
Chapter2 Catalyst 6500 Series Switch and ROM Monitor Commands
Switch CLI
To use multipliers with multiple-character patterns, you enclose the pattern in parentheses. In the
following example, the pattern matches any number of the multiple-character string ab:
(ab)*
As a more complex example, this pattern matches one or more instances of alphanumeric pairs (but not
none; that is, an empty string is not a match):
([A-Za-z][0-9])+
The order for matches using multipliers (*, +, or ?) is to put the longest construct first. Nested constructs
are matched from outside to inside. Concatenated constructs are matched beginning at the left side of the
construct. Thus, the regular expression matches A9b3 but not 9Ab3 because the letters are specified
before the numbers.
Alternation
Alternation allows you to specify alternative patterns to match against a string. You separate the
alternative patterns with a vertical bar (|). Exactly one of the alternatives can match the string. For
example, the regular expression
codex | telebit
matches the string codex or the string telebit but not both codex and telebit.
Anchoring
You can match a regular expression pattern against the beginning or the end of the string. That is, yo u
can specify that the beginning or end of a string contains a specific pattern. You “anchor” these regular
expressions to a portion of the string using the special characters shown in Tab le 1-6.
This regular expression matches a string only if the string start s wi th a bcd:
^abcd
In contrast, this expression is in a range that matches any single letter, as lo n g as it is not the letters a, b,
c, or d:
[^abcd]
With this example, the regular expression matches a string that ends with .12:
$\.12
Contrast these anchoring characters with the special character underscore (_). The underscore matches
the beginning of a string (^), the end of a string ($), parentheses ( ), space ( ), braces { }, comma (,), or
underscore (_). With the underscore character, you can specify that a pattern exist anywhere in the string.
Table1-6 Special Characters Used for Anchoring
Character Description
^ Matches the beginning of the string.
$ Matches the end of the string.