[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] IP address regex golf



"David L. Nicol" <david@kasey.umkc.edu> wrote:
> > > > Anyone have an example of a working regex for perl
> > > > to test for a valid IP
> > > > address that they would be willing to share?  
> > > 
> 
> /^((\d|[01]?\d\d|2[0-4]\d|25[0-5])\.){3}(\d|[01]?\d\d|2[0-4]\d|25[0-5])$/
> 
> or
[non-regex omitted]

Based on David's regex:

/^(?!\.)(?=(.*\.){3})(\.?(\d|[01]?\d\d|2[0-4]\d|25[0-5])){4}$/

  Steven Alexander
  stevena@teleport.com

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe