Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Sandman Newsgroups: comp.lang.php Subject: Re: What this means "(\w|-)+@\w"? Date: Tue, 02 Aug 2011 10:06:17 +0200 Lines: 45 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: individual.net gsR3XV/6BMsazNCSE7KYKAFwBVREyYs7B61qxHDQ8ZjjXW7vs= X-Orig-Path: mr Cancel-Lock: sha1:7pN2YQvnknFgtXsV++sc2Oh7mhA= User-Agent: MT-NewsWatcher/3.5.2 (Intel Mac OS X) X-Face: $@,Vfa$,)%=Qa7L]y)&oZj_\EiHc}}Af0Bei"4a_%)"c6TQ+P/:53>;PNGuWUmkqyeN-qM65foJ[;T_(k;>]&G\T4Lhm:2 ujye2_,iUJFE;NZn>y;.|-hl7g~bIOF1qG\o, "Álvaro G. Vicario" 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? -- Sandman[.net]