Return to Snippet

Revision: 72871
at March 14, 2018 17:35 by plasticbottle


Updated Code
function is_email_valid($email)
{
    return (preg_match('/^[a-zA-z0-9._'+]+@[a-zA-z0-9]+\.([a-z0-9-]{2,4}|[a-z0-9]{2,}+\.[a-z0-9]{2,4})$/', $email) > 0) ? true : false;
}

Revision: 72870
at March 14, 2018 17:32 by plasticbottle


Initial Code
function is_email_valid($email)
{
    return (preg_match('^[a-zA-z0-9._'+]+@[a-zA-z0-9]+\.([a-z0-9-]{2,4}|[a-z0-9]{2,}+\.[a-z0-9]{2,4})$', $email) > 0) ? true : false;
}

Initial URL


Initial Description
It should work for domains like @something.co.uk

note that regex will never really be able to match 100% of e-mail addresses without allowing some false positives

Initial Title
PHP regex e-mail validation

Initial Tags
regex

Initial Language
PHP