title: Java regex - one liner for counting matches
body: <p>Is there a one liner to replace the while loop?</p>
  
  <pre><code>String formatSpecifier = "%(\\d+\\$)?([-#+ 0,(\\&lt;]*)?(\\d+)?(\\.\\d+)?([tT])?([a-zA-Z%])";
  Pattern pattern = Pattern.compile(formatSpecifier);
  Matcher matcher = pattern.matcher("hello %s my name is %s");
  
  // CAN BELOW BE REPLACED WITH A ONE LINER?
  int counter = 0;
  while (matcher.find()) {
      counter++;
  }
  </code></pre>