An Entrepreneur, Coach, IT Consultant, Strategic Adviser, and a Traveler craving to explore and contribute to forming a better society.

Wednesday, August 19, 2009

Email - Regular Expression (Javascript, PHP, PERL Validation)

2 comments :
Email - Regular Expression (Javascript, PHP, PERL Validation)
/^[a-zA-Z0-9][a-zA-Z0-9\w\-\.\_]*@[a-zA-Z0-9\w\-\.\_]+\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/

PHP Source for Email Validation

function emailvalidation( ){
$pattern = "/^[a-zA-Z0-9][a-zA-Z0-9\w\-\.\_]*@[a-zA-Z0-9\w\-\.\_]+\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/";
if( preg_match( $pattern, $email ) )
return true;
else
return false;
}

?>

The above regex is for email

Valid Values:email@gmail.com
email@gmail.co.in
email@gmail.co.uk

Invalid Values:
@gmail.com
gmail.com
email@gmail.co.

2 comments :

Unknown said...

This was of great help ... thank you !!!!

Kathiravan Manoharan said...

Thank you for your compliments. I will be glad to help you out on any specific problems.