Regex for Password Validation
<p>I am looking for a regular expression to validate passwords on following:</p>

<ul>
<li>Passwords must be minimum 7 characters, maximum 50 characters  </li>
<li><p>Passwords must contain characters from at least three of the following four categories: </p>

<ol>
<li>English uppercase alphabet characters (A–Z)</li>
<li>English lowercase alphabet characters (a–z)</li>
<li>Base 10 digits (0–9)</li>
<li>Non-alphanumeric characters (for example, !$#,%)</li>
</ol></li>
</ul>

<p>My try on this is as follows:</p>

<pre><code>^.*(?=.{7,50})(?=.*\d)(?=.*[A-Z]).*$
</code></pre>

<p>This doesn't check special characters, and I am not getting how to make it that passwords must contain characters from at least three of the following four categories.</p>

<p>Can anyone help to suggest a regular expression to validate this password policy?</p>