Re: Regexp with groups and subgroups
Michael McCallum <[email protected]> Tue, 16 Sep 2003 11:44:49 +1200
| Newsgroups | gmane.comp.jakarta.regexp.user |
|---|---|
| Organization | SnapHire Inc |
| Message-ID | <[email protected]> |
Divide and conquer just break up your input into separate interfaces.
something like
String output = getShowOutput();
int index = output.indexOf( "interface:" );
int secondIndex = output.indexOf( "interface:", index );
String firstInterface = output.substring( index, secondIndex );
then do the match on firstInterface and get the values and repeat the process
to get the next interface.
kind regards
Michael
On Tuesday, 16 September, 2003 00:21, Sarika Inamdar wrote:
> Hi All,
>
> We have to write a regular expression to extract some values for mutiple
> interfaces.
>
> For example : We have a command :
>
> "show mpls l2 vc details "
>
> The output of this command gives details of the mpls for mutiple
> interfaces viz :
>
> Local interface: VFI erms1 up
> Destination address: 10.8.99.3, VC ID: 13, VC status: up
> Tunnel label: 29, next hop point2point
> Output interface: PO9/2, imposed label stack {29 40}
> Create time: 1w2d, last status change time: 2d09h
> Signaling protocol: LDP, peer 10.8.99.3:0 up
> MPLS VC labels: local 40, remote 40
> Group ID: local 0, remote 0
> MTU: local 9216, remote 9216
> Remote interface description:
> Sequencing: receive disabled, send disabled
> VC statistics:
> packet totals: receive 143929, send 488
> byte totals: receive 10266253, send 42323
> packet drops: receive 0, send 0
>
> Local interface: VFI ERMS-VPN-2000 up
> Destination address: 10.8.99.3, VC ID: 2000, VC status: up
> Tunnel label: 29, next hop point2point
> Output interface: PO9/2, imposed label stack {29 42}
> Create time: 2d03h, last status change time: 2d03h
> Signaling protocol: LDP, peer 10.8.99.3:0 up
> MPLS VC labels: local 62, remote 42
> Group ID: local 0, remote 0
> MTU: local 1500, remote 1500
> Remote interface description:
> Sequencing: receive disabled, send disabled
> VC statistics:
> packet totals: receive 305, send 306
> byte totals: receive 25925, send 27234
> packet drops: receive 0, send 0
>
> We need to extract the highlighted values like VCD id and the VC
> statistics like ( packet totals, byte totals, packet drops)
>
> We have written a reg exp which will extract the above value. But this
> works only for one interface.
> The reg-exp is :
> VC ID: (\d+),[\w\W\s]+packet totals: receive (\d+), send (\d+)\s+byte
> totals:\s+receive (\d+), send (\d+)\s+packet drops:\s+ receive (\d+),
> send (\d+)
> Can this be enhanced into groups and subgroups to get values for all the
> interfaces listed in the above output ?
> Any help on this is greatly appreciated.
> Thanks in Advance,
> Sarika
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
--
Michael McCallum
Software Engineer
SnapHire Inc.
http://www.SnapHire.com/