title: How to count number or characters match the pattern?
body: <p>Here is my function that checks whether the string is alpha/numeric</p>
  
  <pre><code>public boolean bpIsAlphaNumeric(String s){
      String pattern= "^[a-zA-Z0-9]*$";
      if(s.matches(pattern)){
          return true;
      }
      return false; 
  }
  </code></pre>
  
  <p>It works perfect. Now I need (using same method/pattern) to check that String s contains at least xxx alpha/numeric characters. </p>
  
  <pre><code>//e.g. at least 4 characters should be alphanumeric
  
  String "abc#DE$01%23!##^$"  //true, because it contains - abcDE0123
  String "!$#%#a#b&amp;9$^$##^$"  //false, because it contains only - ab9
  </code></pre>