Re: eregi(mail)

From: Date: Tue, 21 May 2002 18:11:39 +0000
Subject: Re: eregi(mail)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-98624@lists.php.net to get a copy of this message
On Tue, 21 May 2002, Denis L. Menezes wrote: > I use the following code, but it does not work. Is there something wrong? > > If > > (ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_cb¬'[»˜ > apivlÌa > -z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', > $email_address)) One problem (syntax issues aside) is that it doesn't seem to be checking for anything remotely similar to a valid email address. Here's what we use. Not 100% perfect but closer than most, I think: function validate_email ($addr) { return preg_match('/^[^\'"\s,;]+@([a-z0-9]+[a-z0-9\-]*\.)+[a-z0-9]+[a-z0-9\-]*[a-z0-9]+$/i', trim($addr))); } miguel

« previous php.general (#98624) next »