Re: [Exim] Wish list: isIPaddress predicate

Top Page
Delete this message
Reply to this message
Author: Andy Rabagliati
Date:  
To: Exim users list
Subject: Re: [Exim] Wish list: isIPaddress predicate
On Fri, 05 Sep 2003, Nick Cleaton wrote:

> On Fri, Sep 05, 2003 at 03:46:49PM +0100, Nick Cleaton wrote:
>
> Fixing the problem John spotted:
>
>   sub isipaddr
>   {
>       return ($_[0] =~ (/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\z/)
>               && ($1 <= 255) && ($2 <= 255)
>               && ($3 <= 255) && ($4 <= 255)) ? "yes" : "no";
>   }


Or :-

   sub isipaddr
   {
       return ($_[0] =~ (/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\z/)
               && (($1 | $2 | $3 | $4) <= 255)) ? "yes" : "no";
   }


Cheers, Andy!