Specifications
1-8
Catalyst 4500 Series Switch Cisco IOS Command Reference—Release IOS XE 3.5(0)XO
OL_28738-01
Chapter 1 Command-Line In terfa ce
Using the CLI String Search
You can specify a range of single-chara cter patterns to match against command output. For example,
you can create a regular expression that matches a string containing one of th e following letters: a, e, i,
o, or u. One and only one of these characters must exi st in the string for patte rn matchi ng to su cceed. To
specify a range of single-char acter patterns, enc lose the single-char acter patterns in squa re brackets
([ ]). For example,
[aeiou]
matches any one of the five vowels of the lowercase alphabet, while
[abcdABCD]
matches any one of the first four lett ers of the lower- or uppercase a lphabet.
You can simplify ranges by entering only the end points of the range sepa rated by a dash (-). Simplify
the previous range as follows:
[a-dA-D]
To add a dash as a single-character patte rn in your range, include an other dash and precede it with a
backslash:
[a-dA-D\-]
You can also include a righ t square br acket (]) as a singl e-characte r pattern i n your ra nge. To do so, e nter
the following:
[a-dA-D\-\]]
The previous example matche s any one of the first four letters of the lower- or uppercase alphabe t, a
dash, or a right square bracket.
You can reverse the matching of the range by including a caret (^) at the start of the range. This example
matches any letter except the ones listed:
[^a-dqsv]
This example matches anythin g except a right square bracke t (]) or the letter d:
[^\]d]
Multiple-Character Patterns
When creating regular expre ssions, you can also specif y a pattern containing m ultiple characters. You
create multiple-character regular expressions by joining letters, digits, or keyboard characters that do not
have special meaning. For example, a4% is a multiple-character regular expression. Put a backslash in
front of the keyboard characters that have special meaning when you want to remove their special
meaning.
With multiple-character patterns, order is important. The regular expression a4% matches the character
a followed by a 4 followed by a % sign. If the string does not have a4%, in that order, pattern matching
fails. This multiple-character regular expression:
a.
uses the special meaning of the pe riod character to match th e letter a followed by any single character.
With this example, the strings ab, a!, or a2 are all valid matches for the regular expression.
You can remove the special meaning of the period character by putting a backslash in front of it. In the
following expressi on:
a\.
only the string a. matches this regular expression.