title: Regular expression for password complexity
body: <p>I am trying to implement the enforcement of password complexity through regular expressions on both client (JavaScript) and server side (ASP.NET C#).</p>
  
  <p>The rules are the following:</p>
  
  <ul>
  <li>Must be 8-40 characters</li>
  <li>Must contain at least one digit</li>
  <li>Must contain at least one lowercase letter</li>
  <li>Must contain at least one uppercase letter</li>
  <li>Must contain at least one special character</li>
  </ul>
  
  <p>Can you please help construct the regular expression needed to validate the above?</p>