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 Sarika Inamdar <si...@cisco.com> on 2003/06/06 11:43:13 UTC

Regexp help in getting the IP address

Hi All,

We have to get the IP address from the following xml event :

Threshold123(10.77.11.92)2003-06-05T06:20:00.171Z<name>cdfjdp01</name><i
pa
ddress>10.77.11.48</ipaddress><entity>Cisco
CNS-PerfE</entity><version>dev</version><time>2003-06-05T06:20:00.172Z</
time>criticalcleared.1.3.6.1.2.1.2.2.1.10.31885616724LTE2000000000com.ci
sco.das.MibCollector.MibCollector

In general, we should be able to get any CLASS A/B/C Ip address (
1.1.1.1/22.1.1.1/172.29.102.9)

But the issue is, the start of the string contains "threshold<digits>"
followed by<ipaddress> ?

How I differentiate between the ip address and the digits ? Any regexp
which can achieve the same ?

Please let us know on this.

Thanks much in Advance,
Saika


---------------------------------------------------------------------
To unsubscribe, e-mail: regexp-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: regexp-user-help@jakarta.apache.org


RE: Regexp help in getting the IP address

Posted by Sarika Inamdar <si...@cisco.com>.
Thanks Much for the help. Now it works fine with the regexp.

-Sarika

> -----Original Message-----
> From: Schamil Wackenhut [mailto:sw@wacke.org] 
> Sent: Wednesday, June 11, 2003 2:01 PM
> To: Regexp Users List; sinamdar@cisco.com
> Subject: Re: Regexp help in getting the IP address
> 
> 
> * Schamil Wackenhut meinte:
> 
> > * Sarika Inamdar meinte:
> > 
> > > Threshold12310.77.11.922003-06-05T06:20:00.171Z.
> > > ...
> > > Threshold\d+([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})\d{4}-.*
> > > 
> > > This is extracting me the following :
> > > 
> > > 310.77.11.92
> > 
> > Try this: 
> > 
> Threshold\d{3}([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0
> > -5])\.
> > ([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\d{4}-.*
> 
> I forgot the parenthesis around the main expression:
> 
> Threshold\d{3}(([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-
> 4]\d|25[0-5])\.
> ([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5]))\d{4}-.*
> 
> -- 
> You know my name - look up my number. (The Beatles)
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: regexp-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: regexp-user-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: regexp-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: regexp-user-help@jakarta.apache.org


Re: Regexp help in getting the IP address

Posted by Schamil Wackenhut <sw...@wacke.org>.
* Schamil Wackenhut meinte:

> * Sarika Inamdar meinte:
> 
> > Threshold12310.77.11.922003-06-05T06:20:00.171Z.
> > ...
> > Threshold\d+([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})\d{4}-.*
> > 
> > This is extracting me the following :
> > 
> > 310.77.11.92
> 
> Try this:
> Threshold\d{3}([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.
> ([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\d{4}-.*

I forgot the parenthesis around the main expression:

Threshold\d{3}(([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.
([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5]))\d{4}-.*

-- 
You know my name - look up my number. (The Beatles)


---------------------------------------------------------------------
To unsubscribe, e-mail: regexp-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: regexp-user-help@jakarta.apache.org


Re: Regexp help in getting the IP address

Posted by Schamil Wackenhut <sw...@wacke.org>.
* Sarika Inamdar meinte:

> Threshold12310.77.11.922003-06-05T06:20:00.171Z.
> ...
> Threshold\d+([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})\d{4}-.*
> 
> This is extracting me the following :
> 
> 310.77.11.92

Try this:
Threshold\d{3}([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.
([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\d{4}-.*

Or Threshold\d+ if there are more than 3 numbers after Threshold...

ciao,
schamil
-- 
You know my name - look up my number. (The Beatles)


---------------------------------------------------------------------
To unsubscribe, e-mail: regexp-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: regexp-user-help@jakarta.apache.org


RE: Regexp help in getting the IP address

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

We need to extract the regexp
 
Threshold12310.77.11.922003-06-05T06:20:00.171Z.
            -----------

Sorry about the braces, that was for indicating the ipaddress. The
dashed line shows the ipaddress required to be extracted.

Tried the following regexp :

Threshold\d+([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})\d{4}-.*

This is extracting me the following :

310.77.11.92

The digit sequence can be of any length and ip address can be either
CLASS A/B/C

Please help me on this.

Thanks,
Sarika


> -----Original Message-----
> From: Schamil Wackenhut [mailto:sw@wacke.org] 
> Sent: Friday, June 06, 2003 3:30 PM
> To: Regexp Users List; sinamdar@cisco.com
> Subject: Re: Regexp help in getting the IP address
> 
> 
> * Sarika Inamdar meinte:
> 
> > Threshold123(10.77.11.92)2003-06-05T06:20:00.171Z
> > ...
> > <ipaddress>10.77.11.48</ipaddress>
> > ...
> 
> Which of this both addresses do you need?
> 
> > But the issue is, the start of the string contains 
> "threshold<digits>"
> 
> Followed by '('
> 
> > followed by<ipaddress> ?
> 
> Followed by ')'.
> 
> > How I differentiate between the ip address and the digits ?
> 
> What is the difference between the ip adress and digits?
> (xxx.xxx.xxx.xxx)
> 
> > Any regexp which can achieve the same ?
> 
> you first.
> 
> ciao,
> schamil
> -- 
> bash$ :(){ :|:&};:
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: regexp-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: regexp-user-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: regexp-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: regexp-user-help@jakarta.apache.org


Re: Regexp help in getting the IP address

Posted by Schamil Wackenhut <sw...@wacke.org>.
* Sarika Inamdar meinte:

> Threshold123(10.77.11.92)2003-06-05T06:20:00.171Z
> ...
> <ipaddress>10.77.11.48</ipaddress>
> ...

Which of this both addresses do you need?

> But the issue is, the start of the string contains "threshold<digits>"

Followed by '('

> followed by<ipaddress> ?

Followed by ')'.

> How I differentiate between the ip address and the digits ?

What is the difference between the ip adress and digits?
(xxx.xxx.xxx.xxx)

> Any regexp which can achieve the same ?

you first.

ciao,
schamil
-- 
bash$ :(){ :|:&};:


---------------------------------------------------------------------
To unsubscribe, e-mail: regexp-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: regexp-user-help@jakarta.apache.org