title: Java recursive(?) repeated(?) deep(?) pattern matching
body: <p>I'm trying to get <strong><em>ALL</em></strong> the substrings in the input string that match the given pattern.</p>
  
  <p>For example,</p>
  
  <p>Given string: aaxxbbaxb<br>
  Pattern: a[a-z]{0,3}b<br>
  (What I actually want to express is: all the patterns that starts with a and ends with b, but can have up to 2 alphabets in between them)</p>
  
  <p>Exact results that I want (with their indexes):</p>
  
  <p>aaxxb: index 0~4<br>
  axxb: index 1~4<br>
  axxbb: index 1~5<br>
  axb: index 6~8<br></p>
  
  <p>But when I run it through the Pattern and Matcher classes using <code>Pattern.compile()</code> and <code>Matcher.find()</code>, it only gives me:</p>
  
  <p>aaxxb : index 0~4<br>
  axb : index 6~8<br></p>
  
  <p>This is the piece of code I used.</p>
  
  <pre><code>Pattern pattern = Pattern.compile("a[a-z]{0,3}b", Pattern.CASE_INSENSITIVE);
  Matcher match = pattern.matcher("aaxxbbaxb");
  while (match.find()) {
      System.out.println(match.group());
  }
  </code></pre>
  
  <p>How can I retrieve <strong><em>every single piece of string that matches the pattern</em></strong>?</p>
  
  <p>Of course, it doesn't have to use Pattern and Matcher classes, as long as it's efficient :)</p>