Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. If you'd prefer to explore, try our test area to get started. And see here for current known issues.

New Member

explanation on a BGP regex..

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.

Everyone's tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

explanation on a BGP regex..

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

2 REPLIES
Cisco Employee

explanation on a BGP regex..

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

New Member

explanation on a BGP regex..

Thank You Peter. :-)

356
Views
0
Helpful
2
Replies