regex needed

From: Chris Knipe (savage_at_savage.za.org)
Date: 01/18/05


To: <beginners@perl.org>
Date: Tue, 18 Jan 2005 15:31:50 +0200

Lo everyone,

Can someone please give me a regex to parse the following...

Flags: X - disabled, I - invalid, D - dynamic, J - rejected,
C - connect, S - static, r - rip, o - ospf, b - bgp
 # DST-ADDRESS G GATEWAY DISTANCE INTERFACE
 0 S 0.0.0.0/0 r 198.19.0.2 1 SERVER-CORE
 1 S 196.0.0.0/8 r 165.146.192.1 1 National Gateway
 2 DC 198.19.1.0/24 r 0.0.0.0 0 WIRELESS-CORE
 3 Ib 198.19.0.0/24 u 0.0.0.0 200 (unknown)
 4 DC 198.19.0.0/24 r 0.0.0.0 0 SERVER-CORE
 5 DC 192.168.1.0/24 r 0.0.0.0 0 INTERNAL-CORE
 6 DC 165.146.192.1/32 r 0.0.0.0 0 National Gateway
[admin@wsmd-core] >

I want the regex to return the rule number for all route entries that is static (S Flag) on Interface "National Gateway". For added security, I'd like it if the regex will also only return true if the gateway address is part of 165.165.0.0/8 or 165.146.0.0/8

Basically, I need to use the rule number in another command to delete the route entry... So I presume I'll need to extract it via the regex

Hope someone can help me here..

--
Chris.


Relevant Pages

  • Extracting Name Value Pairs
    ... Hi I have a long line of text that I want to parse for name/value pairs ... can i use RegEx to extract name value pairs? ... A resource for the Microsoft Dynamics Community ...
    (microsoft.public.scripting.vbscript)
  • Re: How to parse output from a command
    ... Does RegEx rely on the .NET framework? ... >> I'm trying to find a way to get any string out of any output. ... >> bypass the DOS command all together, thinking there would be an easy way ...
    (microsoft.public.scripting.vbscript)
  • Regexes on the command line
    ... It seems you might need three levels of quoting, for regex, for Java ... strings and for magic command line characters. ...
    (comp.lang.java.programmer)
  • Collecting details from router, striping info, map and regex. Example.
    ... from the host (cisco in this ... an open view command in this case. ... $foo, in this case. ... the regex. ...
    (comp.lang.perl.misc)
  • RE: regex one liner
    ... Subject: regex one liner ... I would like to modify a file 'in place' at the command line with ...
    (perl.beginners)