title: Regular expression to enforce complex passwords, matching 3 out of 4 rules
body: <p>I have the following criteria for creating a regular expression for a password that conforms to the following rules:</p>
  
  <ol>
  <li>The password must be 8 characters long (this I can do :-)).</li>
  </ol>
  
  <p>The password must then contain characters from at least 3 of the following 4 rules:</p>
  
  <ol>
  <li>Upper case</li>
  <li>Lower case</li>
  <li>Numbers </li>
  <li>Non-alpha numeric</li>
  </ol>
  
  <p>I can make the expression match ALL of those rules with the following expression:</p>
  
  <pre><code>/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.[\W]).{8,}$/
  </code></pre>
  
  <p>But I am struggling with how to do this in such a way that it only needs to solve any 3 of the 4 rules.</p>
  
  <p>Can anyone help me out with this?</p>