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

  • submit to reddit
        // Email syntax check

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);


Logan Koester replied on Sun, 2006/09/10 - 8: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.