01-06-2013 11:09 PM - edited 03-04-2019 06:36 PM
Folks,
I had asked this question earlier but just to refresh my discussion on the regex in BGP, I am looking to consolidate my AS numbers 65350 to 65379 into one statement.
Is the below staement correct?
_653[5-7][0-9]$
The regex is supposed to accomadate all the routes originated from AS number 65350 to 65379.
Thanks,
Nikhil.
01-06-2013 11:12 PM
Yes, it's correct.
BR,
Milan
01-06-2013 11:50 PM
Thanks Milan,
I have a small twist to my question here:
I want to advertise these routes learnt from AS 65350 to 65379 only under the condition that the AS path is seen twice in the AS list.
Is the below correct then?
_653[5-7][0-9]_653[5-7][0-9]$
Thanks,
Nikhil.
01-07-2013 01:03 AM
Hi,
that would match different AS numbers from the 65350 - 65379 range too.
_65351_65352$, e.g.
If you want to match only the same AS number seen twice, you need something like
_(653[5-7][0-9])_\1$
for details.
HTH,
Milan
01-07-2013 05:36 AM
something like:
_(653[5-7][0-9])_\2$
is this not supported?
Regards,
Nikhil Kulkarni.
01-07-2013 05:47 AM
Hi,
the document says:
"The integer specifies the occurrence of a parentheses in the regular expression pattern. If you have more than one remembered pattern in your regular expression, then \1 uses the first remembered pattern and \2 uses the second remembered pattern, and so on."
So iy has no sense to use
_(653[5-7][0-9])_\2$
as there is only one pair of parentheses there.
So you need to use
_(653[5-7][0-9])_\1$
in this case.
\2 may be used in more complicated cases where a second pair of parentheses is used to remember the second pattern.
BR,
Milan
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide