Pattern Alternation; Anchor Characters; Underscore Wildcard - Cisco XR 12000 Series Getting Started Manual

Hide thumbs Also See for XR 12000 Series:
Table of Contents

Advertisement

Pattern Alternation

The order for matches using multipliers (*, +, and ?) 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.

Pattern Alternation

Alternation can be used to specify alternative patterns to match against a string. Separate the alternative
patterns with a vertical bar (
expression codex

Anchor Characters

Anchoring can be used to match a regular expression pattern against the beginning or end of the string.
Table A-3
characters.
Table A-3
Character
^
$
For example, the regular expression ^con matches any string that starts with con, and sole$ matches any
string that ends with sole.
In addition to indicating the beginning of a string, the ^ can be used to indicate the logical function "not"
when used in a bracketed range. For example, the expression [^abcd] indicates a range that matches any
single letter, as long as it is not the letters a, b, c, and d.

Underscore Wildcard

Use the underscore to match the beginning of a string (^), the end of a string ($), parentheses (( )) , space
( ), braces ({}), comma (,), and underscore (_). The underscore can be used to specify that a pattern exists
anywhere in the string. For example, _1300_ matches any string that has 1300 somewhere in the string
and is preceded by or followed by a space, brace, comma, or underscore. Although _1300_ matches the
regular expression {1300_, it does not match the regular expressions 21300 and 13000t.
The underscore can replace long regular expression lists. For example, instead of specifying
^1300( ) ( )1300$ {1300, ,1300, {1300} ,1300, (1300, simply specify _1300_.
Cisco IOS XR Getting Started Guide for the Cisco XR 12000 Series Router
A-140
Appendix A
|
). Only one of the alternatives can match the string. For example, the regular
|
telebit matches the string codex or the string telebit, but not both codex and telebit.
shows that regular expressions can be anchored to a portion of the string using the special
Special Characters Used for Anchoring
Description
Matches the beginning of the string.
Matches the end of the string.
Understanding Regular Expressions, Special Characters, and Patterns
OL-24755-01

Advertisement

Table of Contents
loading

Table of Contents