Re: IP regex
Greg Meckes <[email protected]>
| Newsgroups | gmane.comp.db.mysql.perl |
|---|---|
| Message-ID | <[email protected]> |
Here's a quick and dirt way:
use strict;
my $ip = '0.0.0.0.0';
my @ips = split(/\./,$ip);
my $classes = @ips;
if ($classes != 5) {
print "IP not valid\n";
}
else {
print "IP Valid\n";
}
Greg
--- "Gregg R.Allen" <[email protected]> wrote:
> I'm sure this is very simple, I just can't seem to learn Regexes:
>
> I have been given the chore of taking a DB table of client records,
> which has a field called IP address. Whenever a client logs onto our
> site, I'm supposed to display the IP address they logged on from THE
> LAST TIME they visited, as a security measure.
>
> This field is a MySQl varchar(30). Since this field was added at table
> creation, but not used until recently, many of the fields contain NULLs
> or junk text.
>
> Can someone point me in the direction of creating REGEX to test whether
> an IP address is valid. (Valid in the sense of syntax i.e.
> 192.168.24.20 is valid, but
> 277.22.49.75, or 65.23 is not)?
>
> Thanks in advance
>
> Gregg Allen
>
>
> --
> MySQL Perl Mailing List
> For list archives: http://lists.mysql.com/perl
> To unsubscribe: http://lists.mysql.com/[email protected]
>
>
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/[email protected]