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

Re: [FWP] IP address regex golf



At 06:55 PM 4/28/00 -0500, David L. Nicol wrote:
> > > On 22-Mar-2000 George Bonser wrote:
> > > > On Tue, 21 Mar 2000, William X. Walsh 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?
> > >
> > > That should be pretty easy. if a quad is >-1 and <256, it is a legal IP
> > > address.
>
>/^((\d|[01]?\d\d|2[0-4]\d|25[0-5])\.){3}(\d|[01]?\d\d|2[0-4]\d|25[0-5])$/
>
>or
>
>/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/and$1<256and$2<256and$3<256and$4<256

   /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/&&!((1|$1|$2|$3|$4)&256)

--
Peter Scott
Pacific Systems Design Technologies


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