Not PHP, but in js, I use this: function emailCheck(str) { var at="@" var dot="." var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) if (str.indexOf(at)==-1){ return false }
if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ return false } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ return false } if (str.indexOf(at,(lat+1))!=-1){ return false } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ return false } if (str.indexOf(dot,(lat+2))==-1){ return false } if (str.indexOf(" ")!=-1){ return false } return true } Daevid Vincent http://daevid.com > -----Original Message----- > From: John W. Holmes [mailto:[EMAIL PROTECTED] > Sent: Wednesday, October 15, 2003 9:29 PM > To: php list > Subject: [PHP] What's a good regex to validate an email address? ;) > > Heh... I was adding a note to the PHP Manual and I thought it > was really > funny they had to include this note in the "rules": > > (And if you're posting an example of validating email addresses, > please don't bother. Your example is almost certainly wrong for some > small subset of cases. See this information from O'Reilly Mastering > Regular Expressions book for the gory details.) > > lol... > > The link is http://examples.oreilly.com/regex/readme.html in > case anyone > is interested... > > -- > ---John Holmes... > > Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ > > php|architect: The Magazine for PHP Professionals - www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php