DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Email Syntax Check

08.30.2006
| 9088 views |
  • submit to reddit
        // Email syntax check

<?php
function check_email($email)
{
    $atom = '[-a-z0-9!#$%&\'*+/=?^_`{|}~]'; // znaky tvořící uživatelské jméno
    $domain = '[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])'; // jedna komponenta domény
    return eregi("^$atom+(\\.$atom+)*@($domain?\\.)+$domain\$", $email);
}
?>
    

Comments

Logan Koester replied on Sun, 2006/09/10 - 9:05pm

Thank you! My server was being attacked (I got lazy and didn't bother to check some form data before inserting it to the db) and needed an email regex fast, and you were here. :) Saved the day, mate.