This is an example from Wicked Cool PHP, an  very handy book for daily PHP coding.

I am reading this book now.  It has 12 chapters, total 76 tips.

function is_email($email){

   if (! preg_match('/^[A-Za-z0-9!#$%&\'*+-/=?^_`{|}~]+@[A-Za-z0-9]+(\.[A-Za-z0-9]+)[A-Za-z]$/', $email)){
        return false;
    } else {
        return true;
    }
}

The script above utilizes a regular expression to check whether the given email uses proper email characters, and @ sign in the middle, and at least one dot-something on the end.

David Yin

David is a blogger, geek, and web developer — founder of FreeInOutBoard.com. If you like his post, you can say thank you here

4 Replies to “Checking Valid Emaill address with Regular Expression

Leave a Reply

Your email address will not be published. Required fields are marked *