PHP Regular Expression For E-Mail String Checking – String Function

<?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). ?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.