title: How can I count the number of matches for a regex?
body: <p>Let's say I have a string which contains this:</p>
  
  <pre><code>HelloxxxHelloxxxHello
  </code></pre>
  
  <p>I compile a pattern to look for 'Hello'</p>
  
  <pre><code>Pattern pattern = Pattern.compile("Hello");
  Matcher matcher = pattern.matcher("HelloxxxHelloxxxHello");
  </code></pre>
  
  <p>It should find three matches. How can I get a count of how many matches there were?</p>
  
  <p>I've tried various loops and using the <code>matcher.groupCount()</code> but it didn't work.</p>