RE: regular expression once more

From: ying c (bf5tgh1@yahoo.com)
Date: Fri Jul 18 2003 - 10:17:22 GMT-3


I agree with you. It's a little bit confusion, but I
hope the following helps:

http://www.cisco.com/en/US/customer/products/sw/netmgtsw/ps996/products_user_guide_chapter09186a008007fb9e.html
(Watch the wrap):

The following expression matches with a, b, c, or
thing:

[abc(thing)]

That means:

[100] - matches 1 or 0
[(100)] - matches 100
[^100] - matches everything but 1 or 0
[^(100)] - matches everything but 100

The above can be verified from route-server.ip.att.net
with "sh ip bgp reg <regular-expression>".

Chang
#10542
--- "Pete Yeargin (pyeargin)" <pyeargin@cisco.com>
wrote:
> As mentioned before, I would try the following with
> the parentheses
> added in:
>
> _[^(100)]$
>
>
>
>
> -----Original Message-----
> From: nobody@groupstudy.com
> [mailto:nobody@groupstudy.com] On Behalf Of
> Jonathan V Hays
> Sent: Thursday, July 17, 2003 4:25 PM
> To: 'CCIEStudy'; 'Alvarez, Rolando [NCSUS]'; 'Chen
> Kwong Wai William';
> 'Pete Yeargin (pyeargin)'; 'Connie Nie';
> ccielab@groupstudy.com
> Subject: RE: regular expression once more
>
>
> Well, let's try these regular expression out.
> There's any easy way to do
> this using the "show ip bgp quote-regexp" to test.
>
> To review, we are trying to filter routes that
> originate in AS 100.
>
> Here's a BGP table with no filter:
> ----------
> r2#sh ip bgp
> BGP table version is 3, local router ID is 10.1.1.2
> Status codes: s suppressed, d damped, h history, *
> valid, > best, i -
> internal Origin codes: i - IGP, e - EGP, ? -
> incomplete
>
> Network Next Hop Metric
> LocPrf Weight Path
> *> 99.99.99.0/24 10.1.1.1 0
> 0 9 100 i
> *> 130.108.1.0/24 10.1.1.1 0
> 0 9 i
> r2#
> ----------
> Here's how to test. Let's match only networks
> originating from AS 9:
>
> The modifier "| include 10.1.1.1" cuts down on
> unneeded output.
>
> r2#sh ip bgp quote-regexp 9$ | include 10.1.1.1
> *> 130.108.1.0/24 10.1.1.1 0
> 0 9 i
> ----------
> Only networks originating from AS 100:
>
> r2#sh ip bgp quote-regexp 100$ | include 10.1.1.1
> *> 99.99.99.0/24 10.1.1.1 0
> 0 9 100 i
> r2#
> ----------
> The filter from Des doesn't match anything:
>
> r2#sh ip bgp quote-regexp _^100$
>
> r2#
>
> I don't know if the regexp function understands the
> _^ sequence, since
> the ^ in this context means 'beginning of line.' I
> think the ^ can only
> be used for negation inside a character class.
> ----------
> My own suggested filter does not match either:
>
> r2#sh ip bgp quote-regexp [^1][^0][^0]$
>
> r2#
> ----------
> After I thought about it, I realized that the
> desired entry (with only
> AS 9 in the path) won't match either since it only
> has one digit and the
> regexp is looking for 3 digits.
>
> If we change the regex so the last digit only
> matches anything but a
> zero, that would work, but wouldn't meet the
> requirements, since 10,
> 200, 50, would also match.
>
> r2#sh ip bgp quote-regexp [^0]$ | include 10.1.1.1
> *> 130.108.1.0/24 10.1.1.1 0
> 0 9 i
> r2#
> ----------
> In UNIX or Perl regular expressions you might use
> the a bang
> (exclamation point) to negate an expression, as in
> !(100)$ but that does
> not seem to work in IOS.
>
> r2#sh ip bgp quote-regexp !(100)$ | include 10.1.1.1
> r2#
> ----------
> I'm stumped but at least now you all can see how to
> test a regular
> expression.
>
> HTH,
>
> Jonathan
>
>
>



This archive was generated by hypermail 2.1.4 : Wed Aug 06 2003 - 06:52:44 GMT-3