note 5065 deleted from ereg by jmoore

From: Date: Wed, 14 Feb 2001 20:13:40 +0000
Subject: note 5065 deleted from ereg by jmoore
Groups: php.notes 
Request: Send a blank email to php-notes+get-11076@lists.php.net to get a copy of this message
<p>I looked high and low today for a regular expression that would check email addresses, and all of the examples found were incomplete or buggy... so I wrote my own. <p>This code will check an email address for the following: <p>1) Any invalid chars in pop name or domain <p>2) Correct @ separation <p>3) No '.','-','_' at beginning or end of pop name <p>4) No sequential occourances of '..','--','__' or combinations '-.' in pop name <p>5) No '.','-' at beginning or end of domain segment below top level (.com) <p>6) No sequential occourances of '..','--','__' or combinations '-.' in domain <p>7) Top level domain preceeded by '.' and restricted to 2-3 characters <p> <pre>eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,3}$",$email);</pre> <p>I'd like to know if this helps anyone out or if you have any bugs/suggestions since I will be using it alot. Drop me a line!

« previous php.notes (#11076) next »