title: Regex pattern to match these rules
body: <p>I need a regex to match the following rules.</p>
  
  <pre><code>1. Atleast 1 numerical character.
  2. Atleast 1 of these (!, @, #, $, %, _) non-alphanumeric characters. 
  3. Uppercase alphabets.
  4. Lowercase alphabets
  </code></pre>
  
  <p>I tried creating a pattern as below, but the thing is any of the characters can be in any position. I am kind of stuck here.</p>
  
  <pre><code>^[[A-Z]+[a-z]+[0-9]+[!@#\\$%_]+]$
  </code></pre>
  
  <p>These should satisfy each of the above conditions. </p>
  
  <pre><code>1. [0-9]+
  2. [!@#\\$_%]+
  3. [A-Z]+
  4. [a-z]+
  </code></pre>
  
  <p>But how do I group them together so that they can be occur in any order but each group occurs atlest once.</p>
  
  <p><strong>SOLUTION :</strong></p>
  
  <pre><code> ^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#$%_])[A-Za-z0-9!@#$%_]*$
  </code></pre>