FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » What this means "(\w|-)+@\w"?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: What this means "(\w|-)+@\w"? [message #174995 is a reply to message #174790] Tue, 02 August 2011 08:06 Go to previous messageGo to previous message
Sandman is currently offline  Sandman
Messages: 32
Registered: August 2011
Karma:
Member
In article <iv68tf$fla$1(at)dont-email(dot)me>,
"Álvaro G. Vicario" <alvaro(dot)NOSPAMTHANX(at)demogracia(dot)com(dot)invalid>
wrote:

>> I have some problems in regular expression, here is code :
>> function is_email($e_name)
>> {
>> $arr = array("ac","com","net","org","edu","gov","mil","ac\.cn",
>> "com\.cn","edu\.cn","net\.cn","org\.cn");
>> $str = implode("|",$arr);
>> $reg ='/^[0-9a-zA-z](\w|-)+@\w+\.('.$str.')$/';
>> //echo $reg;
>> if(preg_match($reg,strtolower($e_name)))
>> return strtolower($e_name);
>> else
>> return false;
>> }
>
> As already mentioned, it's a terrible way to validate e-mails. Among
> other omissions, it discards like a hundred valid top level domains:
>
> http://en.wikipedia.org/wiki/List_of_Internet_TLDs
>
> If you are interested in the subject, I suggest you read this forum entry:
>
> http://stackoverflow.com/questions/2514810/php-email-validation-question/25 150
> 58#2515058
>
> I'd say the best options is to write your own simple and permissive
> expression, although you can also use a reliable third-party library and
> keep it updated. (I found
> http://code.google.com/p/php-email-address-validation/ but I have no
> references about it.)

What's wrong with the PHP built in email validator?

<?
if (filter_var($email, FILTER_VALIDATE_EMAIL)){
# Do fancy stuff, such as sending fancy email!
}
?>


--
Sandman[.net]
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: upgrade of php & split deprecated = HELP
Next Topic: Re: What is Islam?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 12:40:13 GMT 2024

Total time taken to generate the page: 0.04082 seconds