Reg Expression - valid International email addresses?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nagual

    Reg Expression - valid International email addresses?

    Can anyone please help me with a regular expression
    to test for Valid International Email Addresses?
    Also, which version of javascript (1.2 ?) is needed for same?

    Thanks.
    Regards.


  • David Dorward

    #2
    Re: Reg Expression - valid International email addresses?

    nagual wrote:
    [color=blue]
    > Can anyone please help me with a regular expression
    > to test for Valid International Email Addresses?[/color]

    Yes, I know this says "Perl", not "JavaScript " but read it anyway. OK?



    --
    David Dorward http://david.us-lot.org/
    Redesign in progress: http://stone.thecoreworlds.net/
    Microsoft announces IE is dead (so upgrade):

    Comment

    • Mark Szlazak

      #3
      Re: Reg Expression - valid International email addresses?

      The following uses regular expressions adapted from Jeffery Friedl's
      book to check the format of an email string.

      rxEmail =
      /^\w[-.\w]*\@[-a-b0-9]+(?:\.[-a-b0-9]+)*\.(?:com|edu |biz|org|gov|in t|inf
      o|mil|net|name| museum|coop|aer o|[a-z][a-z])\b/;

      Convert to lower case before testing.

      rxEmail.test(em ail.toLowerCase ());

      Note that the pattern used non-capture parenthesis which are available
      in IE5.5+ and JavaScript 1.5. For older browsers like NN4 replace (?: by
      ( in the above expression.


      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • Jim Ley

        #4
        Re: Reg Expression - valid International email addresses?

        On 12 Jul 2003 16:27:45 GMT, Mark Szlazak <anonymous@devd ex.com>
        wrote:
        [color=blue]
        >The following uses regular expressions adapted from Jeffery Friedl's
        >book to check the format of an email string.
        >
        >rxEmail =
        >/^\w[-.\w]*\@[-a-b0-9]+(?:\.[-a-b0-9]+)*\.(?:com|edu |biz|org|gov|in t|inf
        >o|mil|net|name |museum|coop|ae ro|[a-z][a-z])\b/;
        >
        >Convert to lower case before testing.
        >
        >rxEmail.test(e mail.toLowerCas e());
        >
        >Note that the pattern used non-capture parenthesis which are available
        >in IE5.5+ and JavaScript 1.5. For older browsers like NN4 replace (?: by
        >( in the above expression.[/color]

        My email address has a + in it, you don't seem to list that one
        above...

        Jim.
        --
        comp.lang.javas cript FAQ - http://jibbering.com/faq/

        Comment

        • Mark Szlazak

          #5
          Re: Reg Expression - valid International email addresses?

          Well, then just put the + in.



          *** Sent via Developersdex http://www.developersdex.com ***
          Don't just participate in USENET...get rewarded for it!

          Comment

          • Evertjan.

            #6
            Re: Reg Expression - valid International email addresses?

            Mark Szlazak wrote on 12 jul 2003 in comp.lang.javas cript:[color=blue]
            > Forgot one thing. If you only want international emails then modify the
            > regex to:
            >
            > rxEmail =/^\w[-.\w]*\@[-a-b0-9]+(?:\.[-a-b0-9]+)*\.[a-z][a-z]\b/;[/color]

            ..int

            as in:

            The United Nations agency working to promote health, keep the world safe and serve the vulnerable.


            is THE international domain postfix.


            ..uk, .nl, .ca, etc are the NATIONAL ones


            --
            Evertjan.
            The Netherlands.
            (Please change the x'es to dots in my emailaddress)

            Comment

            • Jim Ley

              #7
              Re: Reg Expression - valid International email addresses?

              On 13 Jul 2003 04:37:37 GMT, Mark Szlazak <anonymous@devd ex.com>
              wrote:
              [color=blue]
              >Well, then just put the + in.[/color]

              and all the thousands of other legal characters... that's the problem
              you're missing. I wouldn't bother with the validation at all... as
              all you'll do is get a junk valid-looking email address, rather than
              simply an incorrect one.

              Jim.
              --
              comp.lang.javas cript FAQ - http://jibbering.com/faq/

              Comment

              • Mark Szlazak

                #8
                Re: Reg Expression - valid International email addresses?

                If your seeking perfection and want to get all those "thousands" of
                emails then speak to God.
                I'm sticking with pragmatic solutions.



                *** Sent via Developersdex http://www.developersdex.com ***
                Don't just participate in USENET...get rewarded for it!

                Comment

                • Jim Ley

                  #9
                  Re: Reg Expression - valid International email addresses?

                  On 13 Jul 2003 14:57:45 GMT, Mark Szlazak <anonymous@devd ex.com>
                  wrote:
                  [color=blue]
                  >If your seeking perfection and want to get all those "thousands" of
                  >emails then speak to God.
                  >I'm sticking with pragmatic solutions.[/color]

                  Because of the + in my email address being rejected, I've not done
                  over 3000 UKP worth of online business with various online agencies
                  this year (mostly computer equipment and travel.) now you may be
                  happy to throw away that business, after all I'm just one bloke right?
                  but are your clients fully aware?

                  Jim.
                  --
                  comp.lang.javas cript FAQ - http://jibbering.com/faq/

                  Comment

                  • Dr John Stockton

                    #10
                    Re: Reg Expression - valid International email addresses?

                    JRS: In article <3f10789b$0$204 $75868355@news. frii.net>, seen in
                    news:comp.lang. javascript, Mark Szlazak <mszlazak@aol.c om> posted at
                    Sat, 12 Jul 2003 21:07:39 :-[color=blue]
                    >Forgot one thing. If you only want international emails then modify the
                    >regex to:
                    >
                    >rxEmail =/^\w[-.\w]*\@[-a-b0-9]+(?:\.[-a-b0-9]+)*\.[a-z][a-z]\b/;[/color]

                    International does not mean foreign; it includes America. Indeed, the
                    OP seems to be Australian. Some US E-mail addresses end, I believe, in
                    ..us, as is right and proper. Many non-US ones end in .com or .net, too.

                    The existence of a national indication in most cases implies a
                    significant connection with that country, with certain well-known
                    exceptions; the converse is not true.

                    Don't believe all that you read in books; even if it was good when
                    written, which is uncertain, the facts might have changed.

                    There is little point in doing much validation on an E-address.

                    It is *impossible* to tell, other than by hearing of delivery, that an
                    E-address is deliverable to; I can change the rules at this site while
                    not connected to the Net. Attempted exact validation risks false
                    negatives (so it needs to be possible to send to an address that the
                    test actually rejects) and false over-confidence.

                    ISTM that the only reasonable validation is one checking that the field
                    is non-empty and that its contents match the minimum requirements; that
                    will deal with cases where some other piece of information is entered.

                    /.+@/+\..+/ seems about as strong a test as is appropriate; if I have
                    it right, check for something @ something . something .

                    E-address validation must be a FAQ candidate; it could provide a basis
                    for an entry on RegExps.

                    --
                    © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
                    <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
                    <URL:http://www.merlyn.demo n.co.uk/js-index.htm> JS maths, dates, sources.
                    <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.

                    Comment

                    • Mark Szlazak

                      #11
                      Re: Reg Expression - valid International email addresses?

                      The pattern with + is just one. I'm still waiting on those thousands.


                      *** Sent via Developersdex http://www.developersdex.com ***
                      Don't just participate in USENET...get rewarded for it!

                      Comment

                      • Disco

                        #12
                        Re: Reg Expression - valid International email addresses?

                        Mark Szlazak wrote:[color=blue]
                        > The pattern with + is just one. I'm still waiting on those thousands.
                        >
                        >[/color]
                        I think the idea is to build an array of every singly possible valid email
                        address. How long is an email address aloud to be? 255 characters for the
                        name part?, then 255 characters for the domain name part?...

                        so, all you need to do is build an array with
                        4.6531388344983 681457769984555 62e+613 elements, then check if the inputted
                        email address is in taht array.
                        Simple.



                        Comment

                        • Jim Ley

                          #13
                          Re: Reg Expression - valid International email addresses?

                          On 14 Jul 2003 01:17:35 GMT, Mark Szlazak <anonymous@devd ex.com>
                          wrote:
                          [color=blue]
                          >The pattern with + is just one. I'm still waiting on those thousands.[/color]

                          You've already been given the link to the perl faq which contains a
                          RegExp many hundreds of chars long which is still not enough.

                          Jim.
                          --
                          comp.lang.javas cript FAQ - http://jibbering.com/faq/

                          Comment

                          • Steve van Dongen

                            #14
                            Re: Reg Expression - valid International email addresses?

                            On 14 Jul 2003 01:17:35 GMT, Mark Szlazak <anonymous@devd ex.com>
                            wrote:
                            [color=blue]
                            >The pattern with + is just one. I'm still waiting on those thousands.[/color]

                            Underscore (_) for starters. 1999 more to go.

                            The point is that even with a perfect regular expression, you don't
                            have any idea whether the address is valid or not. It is impossible
                            to determine unless you send mail to the account and get a response
                            from the person. By attempting to validate the email address, all you
                            do is risk disallowing valid addresses. If you're going to do any
                            validation at all just check whether there is a @ and a subsequent .
                            character.

                            Whenever I sign up for something and I don't really want mail I always
                            use my old ISP's "bitbucket" address because the incoming mail goes
                            directly into the NUL device. It's very efficient.

                            Regards,
                            Steve

                            Comment

                            • Mark Szlazak

                              #15
                              Re: Reg Expression - valid International email addresses?

                              Two of my responses haven't posted over the last two days so I'll post
                              again and address Jim, John and Steve.

                              Jim now points to Tom's large regex and says that's still not enough.
                              Well it actually could be too much for someone else since patterns
                              may never occur in the wild! People may just be interested in whats
                              out there and if a simple regex email format validator good enough!

                              John talks about this when he mentions a topic related to reliability.
                              If a simple format checker is 99.99 percent reliable then what is the
                              significance of those false negatives? It maybe none. He also provides
                              a simple overall pattern but the OP may needs something more specific
                              to filter international emails ... whatever that means.

                              Steve then talks about two issues that are related but seperate. There
                              is the issue of a valid general email format and then the issue of
                              whether a specific instant of it exists.

                              I would be interested in some empirical data on what's out there and
                              how that has changed over time versus what's possible via specs.

                              Thanks.

                              Comment

                              Working...