A regular expression is the character pattern that can be matched against an input string. Regular expressions can be built using letters (A through Z, a through z), numbers (0 through 9) and other keyboard characters, such as the exclamation point (!) or a tilde (~). A regular expression can be a single-character pattern or a multiple-character pattern. Certain keyboard characters such as caret (^) and dollar sign ($) have special meaning and allow complex regular expressions to be built. Characters with special meaning can be used as simple keyboard characters by preceding them with a backslash (\). When a Border Gateway Protocol (BGP) update exits an Autonomous System (AS), the AS path attribute of the route gets updated. The AS number of the AS is prepended to an existing list of AS numbers. BGP can be configured to use regular expressions for route filtering based on the AS path attribute.
To use a regular expression for BGP route filtering, perform these steps:
Create a BGP AS path Access Control List (ACL) with the regular expression that is to be used for matching the AS path attribute in the BGP updates. To define a BGP AS path ACL, issue the ip as-path access-list command in global configuration mode.
To match the configured AS path ACL, create a route map and issue the match as-path command. To create a route map, issue the route-map command in global configuration mode and the match as-path command in route-map configuration mode.
Bind the route map to a BGP neighbor to filter BGP updates being exchanged with it. To apply a route map to incoming or outgoing routes, issue the neighbor route-map command in router configuration mode.
For more information on using a regular expression for BGP route filtering, refer to these documents: