title: How to match specific characters in String n-m times
body: <p>I intends to use REGEX in Java to match a String. For e.g.I have letters <code>'A' 'A' 'A' 'P' 'P' 'L' 'E' 'S'</code>. </p>
  
  <p>I want to check whether a string contains <code>0-3 'A', 0-2 'P', 0-1 'L', 0-1 'E' and 0-1 'S'</code>.</p>
  
  <p>Examples of string which shall pass the check:
  <code>APPLE, APPLES, ALE, PALE... etc</code></p>
  
  <p>This is what I've tried: </p>
  
  <pre><code>if (str.matches("[A]{0,3}[P]{0,3}[L]{0,1}[E]{0,1}[S]{0,1}"))
  </code></pre>
  
  <p><strong>APPLES</strong> successfully passed through the check but not <strong>SAPPLE</strong>.</p>