BGP4 Regular Expression Pattern-matching

The following table illustrates the functions of BGP regular expression pattern-matching characters and illustrates their use.

Table 1. BGP regular expression pattern-matching characters
Regular expression character Function Examples

.

Matches any single character.

0.0 matches 0x0 and 020.

t..t matches strings such as test, text, and tart.

\

Matches the character following the backslash. Also matches (escapes) special characters.

172\.1\.. matches 172.1.10.10 but not 172.12.0.0.

"\." allows a period to be matched as a period.

[ ]

Matches the characters or a range of characters separated by a hyphen, within left and right square brackets.

[02468a-z] matches 0, 4, and w, but not 1, 9, or K.

^

Matches the character or null string at the beginning of an input string.

^123 matches 1234, but not 01234.

?

Matches zero or one occurrence of the pattern. (Precede the question mark with Ctrl-V sequence to prevent it from being interpreted as a help command.)

ba?b matches bb and bab.

$

Matches the character or null string at the end of an input string.

123$ matches 0123, but not 1234.

*

Matches zero or more sequences of the character preceding the asterisk. Also acts as a wildcard for matching any number of characters.

5* matches any occurrence of the number 5 including none.

18\..* matches the characters 18. and any characters that follow 18.

+

Matches one or more sequences of the character preceding the plus sign.

8+ requires there to be at least one number 8 in the string to be matched.

() []

Nest characters for matching. Separate endpoints of a range with a dash (-).

(17)* matches any number of the two-character string.

17 ([A-Za-z][0-9])+ matches one or more instances of letter-digit pairs: for example, b8 and W4.

|

Concatenates constructs. Matches one of the characters or character patterns on either side of the vertical bar.

A(B|C)D matches ABD and ACD, but not AD, ABCD, ABBD, or ACCD.

_

Replaces a long regular expression list by matching a comma (,), left brace ({), right brace (}), the beginning of the input string, the end of the input string, or a space.

The characters _1300_ can match any of the following strings: ^1300$ ^1300space space1300 {1300, ,1300, {1300} ,1300, .