A regular expression for e-mail string checking
<?php
$email = "l@b.ca";
echo preg_match("/^([a-zA-Z0-9])+([.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+.(.[a-zA-Z0-9_-]+)+[a-zA-Z0-9_-]$/",$email); //Would return 1 (true).
echo "<br />";
$bademail = "l.ca";
echo preg_match("/^([a-zA-Z0-9])+([.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+.(.[a-zA-Z0-9_-]+)+[a-zA-Z0-9_-]$/",$bademail); //Would return 0 (false).
?>
Related examples in the same category