Cisco Catalyst 4500 Series Command Reference Manual page 56

Cisco ios command reference
Hide thumbs Also See for Catalyst 4500 Series:
Table of Contents

Advertisement

Using the CLI String Search
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, you
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
Table 1-6
Character
^
$
This regular expression matches a string only if the string starts with abcd:
^abcd
In contrast, this expression is in a range that matches any single letter, as long 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.
For example:
_1300_
matches any string that has 1300 somewhere in the string. The string's 1300 can be preceded by or end
with a space, brace, comma, or underscore. For example:
{1300_
matches the regular expression, but 21300 and 13000 do not.
Using the underscore character, you can replace long regular expression lists, such as the following:
^1300$ ^1300(space) (space)1300 {1300, ,1300, {1300} ,1300, (1300
with
_1300_
Catalyst 4500 Series Switch Cisco IOS Command Reference—Release IOS XE 3.3.0SG and IOS 15.1(1)SG)
1-10
Special Characters Used for Anchoring
Description
Matches the beginning of the string.
Matches the end of the string.
Chapter 1
Command-Line Interface
Table
1-6.
OL-25342 -01

Advertisement

Table of Contents
loading

Table of Contents