4 Replies Latest reply: Apr 26, 2012 5:25 PM by 931076 RSS

    Meaning of regular expression in detail

    931076
      Hi All,

      I am not sure whether this question is in correct forum type but my question is

      what is detail meaning following regular expression ?Please help me to understand this character by character.

      Expression is ^[\\w\\-]([\\.\\w])+[\\w]+@([\\w\\-]+\\.)+[A-Z]{2,4}$

      Thanks,
        • 1. Re: Meaning of regular expression in detail
          sabre150
          Maybe you should study http://www.regular-expressions.info/tutorial.html and http://docs.oracle.com/javase/tutorial/essential/regex/ .

          In general terms, that regular expression is a very poor attempt to check an email address syntax. Very poor because it does not cover the full specification.

          There is another point you should consider - even if the syntax of the email address is correct you cannot know that the address exists.
          • 2. Re: Meaning of regular expression in detail
            931076
            Thanks,

            Yes,you are correct,I have email verification java code,which does it to check if email address is exist,but it can reject sender sometime..and right now my priority is to check
            syntax,as one bad syntax is stopping my whole batch to sent out(its giving messaging exception and come out of loop)

            I would be grateful if i get to know meaning of that expression as i am not that strong in regex... :(


            Thanks agian.
            • 3. Re: Meaning of regular expression in detail
              DrClap
              sabre150 wrote:
              In general terms, that regular expression is a very poor attempt to check an email address syntax. Very poor because it does not cover the full specification.
              Yes. And following on from that: if your application looks at somebody's (valid) e-mail address and tells them it isn't a valid e-mail address, they are going to think you are a fool. And if your application is being used for commercial purposes, that would be a black mark against your company. You're better off not validating e-mail addresses at all than implementing a solution with false negatives.
              • 4. Re: Meaning of regular expression in detail
                931076
                Thanks!!

                This was valuable for me..