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

Re: [FWP] IP address regex golf



Uri Guttman <uri@sysarch.com> wrote:
> >>>>> "PS" == Peter Scott <Peter@PSDT.com> writes:
>   PS> At 11:24 PM 4/28/00 -0500, Keith Calvert Ivey wrote:

>   >> /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/&&($1|$2|$3|$4)<256
> 
>   PS> You're going to need that 1| in front of that chain though,
>   PS> otherwise it does a stringwise or.
> 
> which is ok as the |'s will only generate a digit string which is then
> numerically compared to 256. this is golf, not real life!

No, Peter's right.  I did make a mistake in deleting the 1|
before the $1.  Without it you get false negatives (for 
example, '1' || '255' is '355') and false positives (for 
example, '77' || '999' is '??9').  Note that the results of | 
on stringified digits are not limited to digits: :;<=>? are 
also possible.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC

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