This works for me...
#!/usr/bin/perl -w
while (<>){
print if $_=~/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/;
}
Regards,
Matt
--- William <[EMAIL PROTECTED]> wrote:
> hi,
>
> i want to be able to read a text file and extract only the valid
> ip addresses. however, along with valid ip addresses my code is
> grabbing "periods" and invalid ip addresses, e.g., .xxx,
> www.xxx.yyy . how can i correct this?
>
> =====
> while (<inFILE>) {
> chomp;
> if (($L) = ($_) =~ m/\b([0-9.0-9.0-9.0-9]+)\b/ ) {
> print $L, "\n";
> }
> #etc...
> }
>
> #etc...
> =====
>
>
> tia,
> Bill
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/
- Re: regex question Pete Emerson
- Re: regex question Jeff 'japhy' Pinyan
- Re: regex question Michael Fowler
- Re: Re: Regex question Bruno Veldeman
- extracting substr William
- Re: extracting substr Karen Cravens
- Re: extracting substr Dave Cross
- Re: extracting substr Karen Cravens
- Re: extracting substr iain truskett
- Re: extracting substr William
- Re: Regex question Matt Cauthorn
- Re: Regex question fliptop
- Re: Regex question Chas Owens
- regex question Josh
- Re: regex question Jeff 'japhy' Pinyan
- regex question [EMAIL PROTECTED]
- Re: regex question Jos I. Boumans
- RE: regex question MECKLIN, JOE (ASI)
- regex question rory oconnor
- RE: regex question James Kelty
- Re: regex question Johnathan Kupferer
