title: Java match the same group multiple times
body: <p>I need to match in a sequence of characters the same pattern multiple times.</p>
  
  <p>Eg: For the input <code>Some words &lt;firstMatch&gt; some words &lt;secondMatch&gt; some more words &lt;ThirdMatch&gt;</code> I would need <code>&lt;firstMatch&gt;</code>, <code>&lt;secondMatch&gt;</code>, <code>&lt;thirdMatch&gt;</code></p>
  
  <p>I have tried something like this:</p>
  
  <pre><code>String input = "Some words &lt;firstMatch&gt; some words &lt;secondMatch&gt; some more words &lt;ThirdMatch&gt;";
  Pattern pattern = Pattern.compile( ".*(\\&lt;.*\\&gt;).*" );
  Matcher m = pattern.matcher( input );
  while ( m.find() ) {
           System.out.println( m.group( 1 ) );
  }
  </code></pre>
  
  <p>All I get is <code>ThirdMatch</code></p>
  
  <p>Any help?</p>