RE: regular express question

From: Tim Fletcher (tim@fletchmail.net)
Date: Thu Apr 17 2003 - 21:46:01 GMT-3


Garnet,

Your as-path list will work just fine, as will the one you mentioned from the previous e-mail. They will both meet the requirement. Consider the following regular expression and AS path:

RE: _2400_(.+_)*3500_
AS: 2400 10 20 3500

The 1st underscore matches the beginning of the string, followed by a literal 2400, and the 2nd underscore matches the space between 2400 and 10. Now you might think that the ".+_" would match "10 " for 1 match, then "20 " for a 2nd match, but it really matches "10 20 " in a single match. The reason is that regular expressions are "greedy", meaning they will match as many charters as they can. So in this case, it will match everything up to a space followed by the literal 3500. So in reality, any of the following will work the same.

_2400_(.*_)*3500_
_2400_(.+_)*3500_
_2400_(.*_)?3500_

You just have to make sure you allow for any length string in the middle, followed by a space, and that the middle section is optional.

-Tim Fletcher

At 05:52 PM 4/16/03 -0400, Garnet Ulrich wrote:
>I just tested this stuff and what I found is that even if you enter
>separate
>
>match as-path x
>match as-path y
>
>statements in your route-map, they get automatically converted to a
>single "match as-path x y" statement which means logical OR. I
>confirmed that it takes it as an OR.
>
>The best way I could come up with to match on routes with both ASes in
>the path was the following as-path access-list:
>
>ip as-path access-l 110 permit (_2400_(.+_)*3500_)|(_3500_(.+_)*2400_)
>
>In this example, we must find 2400 and 3500 in either order. I felt the
>access-list below was incorrect because the (.*_)? bit meant we would
>only match if there were zero or one other ASes between the two we care
>about.
>
>Feel free to comment and maybe I'll learn something more. It does
>strike me as odd that such a long regexp is required for something that
>seems so straightforward at first glance.
>
>garnet
>
>On Fri, 2003-04-11 at 06:24, Ryder, Keith wrote:
>> Use a route map but use "match 1 2"
>> This will match only on as-path fiter 1 AND as-path filter 2.
>>
>> If you specify them seperately they will be as-path filter 1 OR as-path
>> filter 2
>>
>> -----Original Message-----
>> From: Daniel Cisco Group Study [mailto:danielcgs@imc.net.au]
>> Sent: 11 April 2003 09:49
>> To: OhioHondo; Daniel Cisco Group Study; ahmed_hassan@rayatelecom.net
>> Cc: ccielab@groupstudy.com
>> Subject: RE: regular express question
>>
>>
>> I checked out the old thread again..... One solution would be:
>>
>> ip as-path access-list 1 _3500_(.*_)?2400_| _2400_(.*_)?3500_
>>
>>
>> Not pretty....
>>
>> Daniel
>>
>> -----Original Message-----
>> From: OhioHondo [mailto:ohiohondo@columbus.rr.com]
>> Sent: Friday, 11 April 2003 12:09
>> To: Daniel Cisco Group Study; ahmed_hassan@rayatelecom.net
>> Cc: ccielab@groupstudy.com
>> Subject: RE: regular express question
>>
>>
>> This was a thread about a month ago. The following works as an OR
>>
>> ip as-path access-list 1 permit _3500_
>> ip as-path access-list 2 permit _2400_
>>
>> route-map AND permit 10
>> match as-path 1 ---- > this shows up as match as-path 1 2
>> match as-path 2 in the config file!!! I tried this.
>> set metric 5000
>>
>> As I recall, if the original solution follows the format suggested at the
>> end of a long discussion. The original solution is shown below and further
>> on in this e-mail thread.
>>
>> ip as-path access-list 1 permit _3550_(.*)2400_|_2400_(.*)3500_
>>
>>
>>
>> -----Original Message-----
>> From: nobody@groupstudy.com [mailto:nobody@groupstudy.com]On Behalf Of
>> Daniel Cisco Group Study
>> Sent: Thursday, April 10, 2003 6:13 PM
>> To: ahmed_hassan@rayatelecom.net
>> Cc: ccielab@groupstudy.com
>> Subject: RE: regular express question
>>
>>
>> I believe that the as-path list will also match paths containing:
>>
>> "3500" and "12400"
>> "2400" and "43500"
>>
>> ie the (.*) also allows other characters to appear before the 2400 or
>> 3500...
>>
>> Anyone agree?
>>
>> Why not use something simple like:
>>
>> ip as-path access-list 1 permit _3500_
>> ip as-path access-list 2 permit _2400_
>>
>> route-map AND permit 10
>> match as-path 1
>> match as-path 2
>> set metric 5000
>>
>>
>> Anything wrong with this logic?
>>
>> Daniel
>>
>>
>> -----Original Message-----
>> From: Ram Shummoogum [mailto:rshummoo@ca.ibm.com]
>> Sent: Friday, 11 April 2003 2:22 AM
>> To: ahmed_hassan@rayatelecom.net
>> Cc: ccielab@groupstudy.com
>> Subject: Re: regular express question
>>
>>
>> Try this.
>>
>> ip as-path access-list 1 permit _3550_(.*)2400_|_2400_(.*)3500_
>> !
>> route-map AND permit 10
>> match as-path 1
>> set metric 5000
>>
>>
>>
>>
>>
>> "Ahmed Hassan" <ahmed_hassan@rayatelecom.net>@groupstudy.com on 04/10/2003
>> 10:35:26 AM
>>
>> Please respond to "Ahmed Hassan" <ahmed_hassan@rayatelecom.net>
>>
>> Sent by: nobody@groupstudy.com
>>
>>
>> To: <ccielab@groupstudy.com>
>> cc:
>> Subject: regular express question
>>
>>
>> Hi GROUP ,
>> Can any one tell me how to make a regular expression that have an logical
>> "AND" condition , for example
>> I wan a regular expression that will filter BGP table to get expressions
>> contain both AS2400 and AS3500 the order is not important
>> best regards
>>
>> *************************************
>> Ahmed Hassan El-shinnawy
>> Network Planning and configuration Engineer
>> Raya Telecom
>> ahmed_hassan@rayatelecom.net
>> *************************************
>>
>>
>> **********************************************************************
>> This email and any files transmitted with it are confidential and
>> intended solely for the use of the individual or entity to whom they
>> are addressed. If you have received this email in error please notify
>> the system manager.
>> This footnote also confirms that this email message has been swept by
>> MIMEsweeper for the presence of computer viruses.
>> www.mimesweeper.com
>> **********************************************************************
>>
>>
>> **********************************************************************
>> This email and any files transmitted with it are confidential and
>> intended solely for the use of the individual or entity to whom they
>> are addressed. If you have received this email in error please notify
>> the system manager.
>> This footnote also confirms that this email message has been swept by
>> MIMEsweeper for the presence of computer viruses.
>> www.mimesweeper.com
>> **********************************************************************
>--
>Garnet Ulrich
>garnet.ulrich@gmx.net
>
>The secret of success is honesty and fair dealing. If you can fake
>those, you've got it made.
>
>[GroupStudy removed an attachment of type application/pgp-signature which had a name of signature.asc]



This archive was generated by hypermail 2.1.4 : Thu May 01 2003 - 13:35:57 GMT-3