Skip to content

Instantly share code, notes, and snippets.

@khoand0000
Created September 11, 2014 15:41
Show Gist options
  • Save khoand0000/29879b41b0b99c6932d1 to your computer and use it in GitHub Desktop.
Save khoand0000/29879b41b0b99c6932d1 to your computer and use it in GitHub Desktop.
<?php
$regex = "/([a-z0-9_]+|[a-z0-9_]+\.[a-z0-9_]+)@(([a-z0-9]|[a-z0-9]+\.[a-z0-9]+)+\.([a-z]{2,4}))/i";
// usage
if(!preg_match($regex, $email)) {
echo "Invalid email address";
}
else {
echo "email is valid";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment