<?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", // Valid
"u2@example.com", // Valid
);
foreach ($values as $value) {
if (preg_match($regex, $value)) {
printf("Found valid address: %s\n", $value);
} else {
printf("INVALID address: %s\n", $value);
}
}
?>
|