Results 1 to 2 of 2

Thread: Regular Expression Help

  1. #1
    Join Date
    Nov 2007
    Location
    USA
    Posts
    170
    Thanks
    8
    Thanked 22 Times in 22 Posts

    Default Regular Expression Help

    I have this regular expression to test for an email:

    /^[a-zA-Z0-9\- ]+\@[a-zA-Z0-9 \-\.]+\.([a-zA-Z]{2,3})$/;


    It works all good except that if I put an email like:

    johndoe@this..com

    It will say its valid even though there are two '.'

    Any idea how I could fix this?
    What is obvious to you might not be to another.


    My Site

  2. #2
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    Try using this, I got it from one of the Dynamic Drive functions. I've tested it against your example and it doesn't allow the double "."


    var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i

Tags for this Thread

Bookmarks

Posting Permissions

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