Re: IP regex

Spenser <[email protected]>
Newsgroups gmane.comp.db.mysql.perl
Message-ID <1099196829.2238.6.camel@localhost>
You could use the MySQL function, INET_ATON() to check for a valid
address.  This first statement below produces a valid number or string. 
The second statement below returns NULL because the IP address given
isn't valid.
   SELECT INET_ATON('192.168.24.20');
   SELECT INET_ATON('277.22.49.75');

Based on this, you could write a Perl script with error checking; have
it check for NULL or not.  Actually, you could put the field for the IP
address inside the function of the SQL statement:

   SELECT INET_ATON(ip_address_column);






> --- "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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.