[Contents] [Prev] [Next] [Index] [Report an Error]

Regular Expression Examples

Table 7 lists some representative regular expressions that you might use in an AS-path access list or community list, along with sample attribute values that match or do not match the regular expression.

Table 7: Sample Regular Expressions

Regular
Expression

Matched AS-Path or Community Attribute

Example

^12

Begins with 12

12 23 4212 629
121245 19

but not
58 12 7

[^12]

Includes any numeral except 1 or 2

44 73 465 69
8

but not
1145 1912
2 49

305$

Ends with 305

89 611 305305
42 30519 1305
6666:305

.5

Includes any one character followed by the numeral 5

89 611 3533 252 12 998
600:500

1.9

Includes a sequence of three characters, where the first character is numeral 1 and the third character is numeral 9

179 35 2433 252 129 48
2129 14600:2129
321:94

.*

Includes any character; matches all AS paths and community lists

 

42*

Includes a number that has a numeral 4 followed by zero or more instances of the numeral 2

67 42 51314
33 252 422 483142
4 339 7831422

1(37)*

Includes a sequence that has a numeral 1 followed by zero or more instances of the pattern 37

137 42 211373737 29 4
1

but not
4 3737 78

42+

Includes a number that has a numeral 4 immediately followed by one or more instances of the numeral 2

67 42 2133 252 422 48

but not
4 329 78

1(37)+

Includes a sequence that has a numeral 1 immediately followed by one or more instances of the pattern 37

1373737 29 44 37137 78
137 42 21

but not
4 372 2121 37 5
1 456 881

42?

Includes a number that has a numeral 4 followed by zero or only one instance of the numeral 2

67 42 714 359 78

but not
33 252 422 48

1(37)?

Includes a sequence that has a numeral 1 followed by zero or only one instance of the pattern 37

137 42 2153 612 49
1

but not
4 13737 78

7..

Includes a sequence of three characters, where the first character is numeral 7

600 700 10025 7771

In the following examples, the three characters are 7, space, 8:
307 800 6127 888 999

^7..

Includes a number in the range 700 – 799

6127 723 999 700 100 600

but not
25 7771307 800

^7..$

Consists only of a number in the range 700 – 799

723 700

but not
25 7771307 800
6127 723 999700 100 600

[621]

Includes any of the numerals 6, 2, or 1

60 4334 545 92
200710
86 53

The regular expression [162] has the same results.

[0-9]

Includes any number in the range 0–9

 

^\(22 431\)

(AS-path attribute only) Begins with the AS-confed-set or AS-confed-seq (22 431)

(22 431) 102(22 431) 55 76

but not
43 (22 431) 522 431 59

{41 19}

(AS-path attribute only) Includes the AS-set or AS-seq {41 19}

{41 19} 53 76 {41 19} 17
255 {41 19}

but not
3 41 19 41 19 532

101 102 | 103 105

Includes either sequence 101 102 or sequence 103 105

43 101 102 5103 105 22

but not
19 102 101102 103

_200_

Includes the number 200 (as opposed to the pattern consisting of numeral 2, numeral 0, numeral 0)

Our implementation of regular expressions is not literal. Substring matching is enabled by default. Specifying 200 (no underscores) results in a match on 200 and on 2005. The underscore metacharacter disables substring matching.

33 200 422 48^200$
^200 500$

but not
33 20 422 48 51 2005

For information about using AS-path access lists, see Access Lists. For information about using community lists, see Community Lists.


[Contents] [Prev] [Next] [Index] [Report an Error]