cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
910
Views
0
Helpful
2
Replies

explanation on a BGP regex..

nikhil.kulkarni
Level 1
Level 1

Team,

I am a bit new to this regular expressions and to troubleshoot some routing I want to know what the following regex exactly means:

^(65030)?$

Regards,

Nikhil.

1 Accepted Solution

Accepted Solutions

Peter Paluch
Cisco Employee
Cisco Employee

Hello Nikhil,

Let's break down the regex:

  • ^ - this symbol stands for the beginning of a string. It means that the matched string must exactly start with the expression that immediately follows the ^ symbol.
  • (65030) - this is a constant string, in this case, the AS number. Having it enclosed in parentheses allows subsequent operators to act on the entire string - otherwise, they would act only on the last character preceding them.
  • ? - this symbol is a quantifier saying that the preceding character or group of characters may appear at most once, i.e. either not be present or be present exactly once
  • $ - this symbol stands for the end of a string. It means that the matched string must exactly end with the expression that immediately precedes the $ symbol.

So the regex ^(65030)?$ stands either for "" or for "65030". In the AS_PATH terms, it means "a prefix either originated in the local AS or originated in the neighboring AS 65030".

Please feel welcome to ask further!

Best regards,

Peter

View solution in original post

2 Replies 2

Peter Paluch
Cisco Employee
Cisco Employee

Hello Nikhil,

Let's break down the regex:

  • ^ - this symbol stands for the beginning of a string. It means that the matched string must exactly start with the expression that immediately follows the ^ symbol.
  • (65030) - this is a constant string, in this case, the AS number. Having it enclosed in parentheses allows subsequent operators to act on the entire string - otherwise, they would act only on the last character preceding them.
  • ? - this symbol is a quantifier saying that the preceding character or group of characters may appear at most once, i.e. either not be present or be present exactly once
  • $ - this symbol stands for the end of a string. It means that the matched string must exactly end with the expression that immediately precedes the $ symbol.

So the regex ^(65030)?$ stands either for "" or for "65030". In the AS_PATH terms, it means "a prefix either originated in the local AS or originated in the neighboring AS 65030".

Please feel welcome to ask further!

Best regards,

Peter

Thank You Peter. :-)