At 04:53 PM 9/21/2001 +0200, walter valenti wrote:
>How i can write a reg. expr for find the IP address in log file like:
>
>15:46:25.967683 194.244.46.38.1412 > 207.88.221.53.119: . ack 1115 win
>8760 (DF)
>15:46:26.600505 194.244.46.38.1412 > 207.88.221.53.119: P 15:21(6) ack
>1115 win 8760 (DF)
>15:46:26.600972 194.244.46.38.1412 > 207.88.221.53.119: F 21:21(0) ack
>1115 win 8760 (DF)
>15:46:26.604361 194.244.46.38.1412 > 207.88.221.53.119: R
>14048899:14048899(0) win 0 (DF)
>15:46:26.822313 207.88.221.53.119 > 194.244.46.38.1412: . ack 22 win
>24820 (DF)
Many people react to the "match an IP address" question with a massive
regex that cannot possibly match anything else. However, in the case of
something as regular as this type of input, I say, just go for the simplest
thing that'll work. You're not parsing freeform text here. So:
First IP:
if (/ ([\d.]+)\.) { .... use IP in $1
Second IP:
if (/> ([\d.]+)\.) { ... use IP in $1
Peter Scott
[EMAIL PROTECTED]
http://www.perldebugged.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]