| 
	
 | 
 Posted by AnrDaemon on 12/19/07 22:14 
Greetings, Rik Wasmus. 
In reply to Your message dated Friday, December 14, 2007, 19:26:27, 
 
>> I have written a function using ereg(). 
>> 
>> function ValidateOpinion() 
>> { 
>>  $reEmail = '^[A-Za-z0-9-.]{1,40}@[A-Za-z0-9-.]{1,70}$'; 
 
> Perhaps: 
> $reEmail = '^[A-Za-z0-9.-]{1,40}@[A-Za-z0-9.-]{1,70}$'; 
> .. allthough this would tell you lot's of valid emailaddresses are   
> invalid... 
 
> The ereg* functions should not be used anymore, use the preg_* functions   
> if you can. And it's a bogus email-validator anyway. Check Friedl's   
> example of a real regex emailaddress validator, and then quickly forget   
> trying to validate the whole thing (you might want to test for an MX   
> record of the domain though). 
 
Speaking on e-mail validation (and hostname validation as more common problem) 
I've found an interesting trick to define a hostname as Perl RE. 
 
Excluding the part with protocol and port definition and access 
credentials, it looks like:  
 
^[0-9a-z]+(?:[\.\-][0-9a-z]+)*$ 
 
 
--  
Sincerely Yours, AnrDaemon <anrdaemon@freemail.ru>
 
  
Navigation:
[Reply to this message] 
 |