Cisco 4500M Command Reference Manual page 30

Command reference
Hide thumbs Also See for 4500M:
Table of Contents

Advertisement

Using the CLI String Search
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
Table1-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_
Parentheses for Recall
As shown in the
expressions to multiply the occurrence of a pattern. You can also use parentheses around a single- or
multiple-character pattern to remember a pattern for use elsewhere in the regular expression.
To create a regular expression that recalls a previous pattern, you use parentheses to indicate a
remembered specific pattern and a backslash (\) followed by an integer to reuse the remembered pattern.
The integer specifies the occurrence of the parentheses in the regular expression pattern. If you have
more than one remembered pattern in your regular expression, then \1 indicates the first remembered
pattern, \2indicates the second remembered pattern, and so on.
Catalyst4500 Series SwitchCiscoIOS Command Reference—Release 12.2(18)EW
1-10
Special Characters Used for Anchoring
Description
Matches the beginning of the string.
Matches the end of the string.
"Multipliers" section on
page1-9, you use parentheses with multiple-character regular
Chapter1
Command-Line Interface
Table1-6
.
78-16201-01

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ws-c4507r4500 series

Table of Contents