Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Regex For Email

  1. #1
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    911
    Thanks
    302
    Thanked 2 Times in 2 Posts

    Question Regex For Email

    Hi PPL,

    I wrote a regex to verify an email address

    Code:
    if(!preg_match("^[a-z0-9]+@{1}[a-z0-9-]+\.{1}[a-z]{2,4}\.?[a-z]{0,2}$",$myemail))
    echo "Invalid Email";

    Please take a look and tell me if this will work for all type of emails, For example:

    abc@domain.co.uk
    OR
    abc@domain.info
    OR
    abc@domain.com

    and other emails also...


    Thanx

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    There's a lot more to it than what you've covered. The website www.ilovejackdaniels.com has an article that discusses email validation and provides a script that does a good job of covering all email naming rules. I can't get to that website from work but if you go there and search "email" you'll find it.

  • #3
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    911
    Thanks
    302
    Thanked 2 Times in 2 Posts
    Hi,

    Is there any tool you use to validate this?

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Now that I'm home I can see the website and the guy changed his domain to addedbytes.com. Here's the article:

    http://www.addedbytes.com/php/email-address-validation/

  • Users who have thanked Fumigator for this post:

    westes (11-06-2008)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •