Re: parsing [one more]

From: Fagyal, Csongor (concept@conceptonline.hu)
Date: Mon Apr 07 2003 - 08:18:47 EDT


Tim Woodcock wrote:

>To be strictly correct, we more in the regex.
>
>If I request "my domain.com" I do not expect to end up with mydomain.com.
>Sure the space is invalid, but it is an error, and should be diagnosed as
>an error.
>
>What you are looking for is this: s/^\s+|\s+$//g
>
>
>
Or maybe

$domain = lc($domain);
if ($domain) =~ /^\s*([a-z0-9]+-?)+[a-z0-9]+\.[a-z]{2,4}\s*$/) {
    ($domain) = ($domain =~ /^\s*(\S+)\s*$/);
} else {
    die ($DOMAIN_FORMAT_EXCEPTION."\n");
}

Not tested, not 100% perfect, not very nice, but should work. (Doesn't
work for UTF8 domains, though.)

- Cs.



This archive was generated by hypermail 2.1.3 : Tue Oct 19 2004 - 23:37:41 EDT