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

Re: [FWP] IP address regex golf



Jeff Pinyan wrote:
> 
> On Apr 29, Rick Delaney said:
> 
> >Jeff Pinyan wrote:
> >>
> >> A different flavor of the beast:
> >>
> >>     do{$1>255||$b++>3and$a=1while/\G(\d+)(\.|$)/g;!$a};
> >
> >    4==grep $_<256,/\G(\d+)(?:\.|$)/g;
> >    4==grep $_<256,/\G(\d+)(?:\.|\z)/g;
> 
> Hooray!  Someone went with my idea.  

\G is just too much fun to resist.  :-)

> Sigh, if only there was some variant of grep() that does what Tom 
> (or was it Larry) said would be like a first() function...

I don't see that would help here. i.e.

    !grep $_>255,/\G(\d+)(?:\.|\z)/g;

isn't correct since it will return true for random garbage.  But perhaps
you had something else in mind.

-- 
Rick Delaney
rick.delaney@home.com

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