title: Java Regular Expression Matching for hh:mm:ss in String
body: <p>I am parsing a file and it has time based entries in it. format is like:</p>
  
  <pre><code>00:02:10-XYZ:Count=10
  00:04:50-LMK:Count=3
  </code></pre>
  
  <p>Here what I want is to extract the time value from string line</p>
  
  <p>I have searched many links and couldn't find out the thing what I want, eventually I have written this code.</p>
  
  <pre><code>    Pattern pattern = Pattern.compile("((?i)[0-9]{1,2}:??[0-9]{0,2}:??[0-9]{0,2})"); //(?i)[0-9]{1,2}:??[0-9]{0,2}:??[0-9]{0,2}  //\\d{1,2}:\\d{1,2}:\\d{1,2}
      Matcher matcher;
      List&lt;String&gt; listMatches;
  </code></pre>
  
  <p>Below is the loop where I apply logic</p>
  
  <pre><code>    for(int x = 0; x &lt; file_content.size(); x++)
      {
              matcher= pattern.matcher(file_content.get(x));
              listMatches = new ArrayList&lt;String&gt;();
              while(matcher.find())
              {
                  listMatches.add(matcher.group(1));
                  break;
              }
       }
  </code></pre>
  
  <p>I want when "matcher.find()" gives true it returns me [00:02:10] in first iteration and [00:04:50] in 2nd iterations.</p>