title: Email validation Regex JAVA
body: <p>I have a requirement to have email validation using java regex same as I already have on JSP. When I am copying regex from JSP to JAVA, I am getting an error.However, in JSP it is working fine.</p>
  
  <pre><code>if (null != email) {
              String regex = "^([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{1,6}))?$";
              Pattern pattern = Pattern.compile(regex);
              Matcher matcher = pattern.matcher(email);
              if (!matcher.matches()) {
                  addFormException(new DropletException("Email not valid "));
              }
          }
  </code></pre>