}
// Taken from www.php.net eregi() user comments
-function VALIDATE_EMAIL ($email) {
+function isEmailValid ($email) {
// Compile email
$email = COMPILE_CODE($email);
// Check first part of email address
- $first = "[-a-z0-9!#$%&\'*+/=?^_<{|}~]+(\.[-a-zA-Z0-9!#$%&\'*+/=?^_<{|}~]+)*";
+ $first = '[-a-z0-9!#$%&\'*+/=?^_<{|}~]+(\.[-a-zA-Z0-9!#$%&\'*+/=?^_<{|}~]+)*';
// Check domain
- $domain = "[a-z0-9-]+(\.[a-z0-9-]{2,5})+";
+ $domain = '[a-z0-9-]+(\.[a-z0-9-]{2,5})+';
// Generate pattern
- $regex = '^'.$first.'@'.$domain.'$';
+ $regex = '@^' . $first . '\@' . $domain . '$@iU';
// Return check result
- // @TODO eregi() should be rewritten here
- return eregi($regex, $email);
+ // @NOTE altered the regex-pattern and added modificator i (match both upper and lower case letters) and U (PCRE_UNGREEDY) to work with preg_match the same way as eregi
+ return preg_match($regex, $email);
}
// Function taken from user comments on www.php.net / function eregi()