<?php
$regex = "/^[\w\d!#$%&'*+-\/=?^'{|}~]+(\.[\w\d!#$%&'*+-\/=?^'{|}~]+)*@([a-z\d][-a-z\d]*[a-z\d]\.)+[a-z][-a-z\d]*[a-z]$/";
$values = array(
"user@example.com",
"user@example"
);
foreach ($values as $value) {
if (preg_match($regex, $value)) {
printf("Found valid address: %s\n", $value);
} else {
printf("INVALID address: %s\n", $value);
}
}
?>
|