BGP Regular Expressions
| Character | Function |
| . | Match any single character |
| \ | Match the following character |
| [ ] | Match the characters or a range of characters separated by a hyphen |
| ^ | Beginning of an input string |
| $ | End of an input string |
| ? | Match zero or one occurrence |
| * | Match zero or more sequences of the character preceding the asterisk. Also acts as a wildcard for matching any number of characters |
| + | Match one or more sequences of the character preceding the plus sign |
| ( ) | Logical grouping |
| | | Concatenates constructs. Matches one of the characters or character patterns on either side of the vertical bar |
| – | Match a comma (,), left brace {, right brace }, the beginning of the string, the end of the string, or a space |
| _ | Match the space between AS number or end of AS_PATH list |
Common Examples of Regular Expressions for BGP
| Expression | Description |
| ^$ | Locally originated prefixes , no path list |
| _254$ | Prefixes originated from AS254 |
| _254_ | Prefixes containing AS254 (transit AS) |
| ^254_ | Prefixes learned from directly adjacent AS254 |
| ^[0-9]+$ | Prefixes learned from all directly connected AS |
| ^([0-9]+)_254 | Prefixes from AS254 when its one AS away |
| ^254_([0-9]+) | Prefixes from clients of directly connected AS254 |
| ^(254_)+([0-9]+_) | Prefixes from clients of adjacent AS254, accounting for AS254 doing AS_PATH prepending |
| ^254_([0-9]+_)+ | Prefixes from clients of adjacent AS254, accounting for clients doing AS_PATH prepending |
| ^\(65000\) | Prefixes learned from Confederation peer 65000 |
| ^([0-9]+)(_\1)(_\1) | Prefixes from any AS that is repeated three times |

