Cisco AS - Regular Expression


A regular expression is a pattern to match against an input string. By building a regular expression we specify a string that input must match. In case of BGP we are specifying a string consisting of path information that an input should match.
The regular expression is composed of the following:

A- Ranges:
A range is a sequence of characters contained within left and right square brackets. ex: [abcd]

B- Atoms:
An atom is a single character

. (Matches any single character)
^ (Matches the beginning of the input string)
$ (Matches the end of the input string)
\character (Matches the character)
_ (Matches a comma(,), left brace ({), right brace (}), the beginning of the input string, the end of the input string, or a space.)

C-Pieces:
A piece is an atom followed by one of the symbols:

* (Matches 0 or more sequences of the atom)
+ (Matches 1 or more sequences of the atom)
? (Matches the atom or the null string)

D- Branch:
A branch is a 0 or more concatenated pieces.

Examples of regular expressions follow:

a* any occurrence of the letter a, including none
a+ at least one occurrence of a should be present
ab?a this will match aa or aba

ex:
_100_(via AS100)
^100$ (origin AS100)
^100 .* (coming from AS100)
^$ (originated from this AS)