[c-nsp] Expression to match 1, 2, or 3 AS paths

Oliver Boehmer (oboehmer) oboehmer at cisco.com
Tue Jun 17 08:42:50 EDT 2008


Tim Franklin <> wrote on Tuesday, June 17, 2008 12:05 PM:

> On Sat, June 14, 2008 5:08 am, Diogo Montagner wrote:
> 
>> Some days ago I was trying to identify prepends using regular
>> expressions without knowing the AS.
> 
> You can do this with regexp back-references.
> 
> ([0-9]+)(_\1)+
> 
> will match any AS that's prepended at least once, and
> 
> ([0-9]+)(_\1)*
> 
> will match the same AS any number of times.  You could use explicit
> repetitions of '_\1' if you want to match a specific number of
> prepends. 

when using pattern recalls (i.e. \1,...), please check the DDTS
mentioned in
http://www.cisco.com/warp/public/707/cisco-sr-20070912-regexp.shtml as
they could lead to a stack overflow..

	oli


More information about the cisco-nsp mailing list