note 38272 rejected from function.ereg by pollita

From: Date: Mon, 15 Dec 2003 02:34:01 +0000
Subject: note 38272 rejected from function.ereg by pollita
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-61962@lists.php.net to get a copy of this message
Note Submitter: thehiddenfire@yahoo.com ---- I've developed this function for use in both PHP and javascript. It checks for the validity of the syntax of an email address and allows multiple subdomains and use of periods (.), hypens (-) and underscores (_) in throughout the entire string. The only things it doesn't check for is valid IP address in the domain section of the email address which could very well be possible (e.g.: email@127.0.0.1). function email_syntax($addr) { $exp = "^[A-Za-z0-9_][A-Za-z0-9\.{0,1}\-{0,1}_]*[A-Za-z0-9]@" . // name@ "[A-Za-z0-9_][A-Za-z0-9\.{0,1}\-{0,1}_]*[A-Za-z0-9]\." . // (sub)domain(s) "[A-Za-z0-9_]([A-Za-z0-9\.{0,1}\-{0,1}])*[A-Za-z0-9]*$"; // domain.tld (top level domain) return ereg($exp, $addr); } (code may wrap, sorry) http://gha.kicks-ass.org

« previous php.notes (#61962) next »