Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #2691
| From | Sandman <mr@sandman.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: What this means "(\w|-)+@\w"? |
| Date | 2011-08-02 10:06 +0200 |
| Message-ID | <mr-0FA206.10061702082011@News.Individual.NET> (permalink) |
| References | <b2cdc780-b6d4-4b6e-a01e-444a616c0fe0@r18g2000vbs.googlegroups.com> <iv68tf$fla$1@dont-email.me> |
In article <iv68tf$fla$1@dont-email.me>,
"Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.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/25150
> 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]
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What this means "(\w|-)+@\w"? zhang yun <bigzhangyun@gmail.com> - 2011-07-07 06:58 -0700
Re: What this means "(\w|-)+@\w"? Michael Fesser <netizen@gmx.de> - 2011-07-07 17:39 +0200
Re: What this means "(\w|-)+@\w"? Eli the Bearded <*@eli.users.panix.com> - 2011-07-07 18:23 +0000
Re: What this means "(\w|-)+@\w"? Michael Fesser <netizen@gmx.de> - 2011-07-07 21:12 +0200
Re: What this means "(\w|-)+@\w"? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-07-07 21:12 +0200
Re: What this means "(\w|-)+@\w"? Eli the Bearded <*@eli.users.panix.com> - 2011-07-08 06:05 +0000
Re: What this means "(\w|-)+@\w"? "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-07-08 08:42 +0200
Re: What this means "(\w|-)+@\w"? Sandman <mr@sandman.net> - 2011-08-02 10:06 +0200
Re: What this means "(\w|-)+@\w"? "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-08-02 11:50 +0200
Re: What this means "(\w|-)+@\w"? "Peter H. Coffin" <hellsop@ninehells.com> - 2011-08-02 07:56 -0500
Re: What this means "(\w|-)+@\w"? Eli the Bearded <*@eli.users.panix.com> - 2011-08-02 20:53 +0000
Re: What this means "(\w|-)+@\w"? "Peter H. Coffin" <hellsop@ninehells.com> - 2011-08-03 08:32 -0500
Re: What this means "(\w|-)+@\w"? "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-08-03 10:55 +0200
Re: What this means "(\w|-)+@\w"? "Peter H. Coffin" <hellsop@ninehells.com> - 2011-08-03 08:46 -0500
Re: What this means "(\w|-)+@\w"? Sandman <mr@sandman.net> - 2011-08-03 00:21 +0200
Re: What this means "(\w|-)+@\w"? Eli the Bearded <*@eli.users.panix.com> - 2011-08-03 07:45 +0000
Re: What this means "(\w|-)+@\w"? Sandman <mr@sandman.net> - 2011-08-03 10:02 +0200
Re: What this means "(\w|-)+@\w"? Eli the Bearded <*@eli.users.panix.com> - 2011-08-05 00:05 +0000
csiph-web