[thelist] regex for email check

Joe Crawford joe at artlung.com
Mon Jan 1 01:33:08 CST 2001


Adrian Fischer wrote:
> big ask at short notice on new years eve (for some...I had mine last night)
> I know but does anyone have a down and dirty check for things like "@" and
> "." in an email .
> Im assuming it would be something like this:
> 
> death("You must enter a valid email addres") if (($form{'email'} ne "stuff
> in here?????.")
> 
> any help would be appreciated.

Back here in the year 2000 I have been using this in PHP which I got
somewhere and works pretty well:

function is_an_email_address($e) {
// returns 1 if it's an email address.
// returns 0 if it's not.
	if (eregi("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}\$", $e)==1)
		{ return 1;}
		else
		{ return 0;};
	}

	Happy New Year to you all!

		- Joe
-- 
Joe Crawford <mailto:joe at artlung.com>
 * I am a Web Designer and Developer;
 * Find out about me at : http://www.ArtLung.com
 * A Mailing List for San Diego Web Folks : http://WebSanDiego.org




More information about the thelist mailing list