title: Regex expression for password rules
body: <p>I have a requirement for password rules. Following are the rules.</p>
  
  <p>The password must follow the following guidelines:</p>
  
  <ul>
  <li>Be at least eight characters long</li>
  <li>Contain 3 of these 4 options: lower case letter, upper case letter, number, or special character</li>
  <li><p>When user specifies a password that does not meet the above rules, return message stating:</p>
  
  <p>Password must be at least 8 characters long and contain 3 of the 4 following options:</p>
  
  <ul>
  <li>Lower case letter (a-z)</li>
  <li>Upper case letter (A-Z)</li>
  <li>Number (0-9)</li>
  <li>Special character (!@#$%^&amp;')</li>
  </ul></li>
  </ul>
  
  <p>Please help me to get a regex expression to handle above conditions.</p>
  
  <p>i appreciate all your help. following is the solution for my requirement</p>
  
  <pre><code>if(password.matches("^(?=.*[0-9]).{1,}$")){
  validCount++;
  }
  if(password.matches("^(?=.*[a-z]).{1,}$")){
  validCount++;
  }
  if(password.matches("^(?=.*[A-Z]).{1,}$")){
  validCount++;
  }
  if(password.matches("^(?=.*[@#$%^&amp;+=]).{1,}$")){
  validCount++;
  }
  return validCount &gt;= 3 ? true : false;
  </code></pre>
  
  <p>Thanks,
  Ramki</p>