You are viewing a plain text version of this content. The canonical link for it is here.
Posted to regexp-user@jakarta.apache.org by Celestino Bellone <ce...@sda.it> on 2003/09/10 10:39:59 UTC

problem with regexp

Hi everybody,
I'm looking for a regular expression that matches strings like this:

12345678910AA

for the 'numeric block' the best way to write this is: 
\d{11}

but, for the 'alphabetical block' there's a 'little'(?) problem...
this block must not be equals to IT, 
so that the regExp must matches 11111111111II or 11111111111NT
but not 11111111111IT

there are someone that can help me to solve this problem?

thanks a lot
Celestino


RE: Regexp with groups and subgroups

Posted by Sarika Inamdar <si...@cisco.com>.
Hi,

Thanks a lot for the advice.

But , we cannot change the code, since we have one common code which
parses the reg-exp and extracts the groups.

So we want to write the reg-exp with nested groups.Each group extracted
is the "Local interface " group. The attributes we want to collect from
this group will be the subgroups.

Is this possible using reg-exp ?

We did the following :

(Local interface: [\w\W\s]+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+))+

With this, am able to extract only the last group.  Any hints, ideas on
how to proceed on this would be of great help.

Thanks Again,
Sarika

> -----Original Message-----
> From: Michael McCallum [mailto:gholam@xtra.co.nz] 
> Sent: Tuesday, September 16, 2003 5:15 AM
> To: Regexp Users List
> Subject: Re: Regexp with groups and subgroups
> 
> 
> 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: regexp-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: regexp-user-help@jakarta.apache.org
> 
> -- 
> Michael McCallum
> Software Engineer
> SnapHire Inc.
> http://www.SnapHire.com/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: regexp-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: regexp-user-help@jakarta.apache.org
> 
> 


Re: Regexp with groups and subgroups

Posted by Michael McCallum <gh...@xtra.co.nz>.
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: regexp-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: regexp-user-help@jakarta.apache.org

-- 
Michael McCallum
Software Engineer
SnapHire Inc.
http://www.SnapHire.com/

Regexp with groups and subgroups

Posted by Sarika Inamdar <si...@cisco.com>.
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