Capturing groups are indexed from left to right, starting at one. Group zero denotes the entire pattern,
So in your for loop, you may have 2 groups, but you start indexing from 0. group(0) isn't included in the groupCount() return value. So if you just want the groups counted from groupCount() you should start the for index at 1, not zero:
But this is only part of the problem. The Regex you are using will only match one group in the String at a time, because you don't give it a pattern where multiple groups are captured. So the code as provided only gives you the first group of the (first) match that is found. This is fine, you probably want that. You just want to loop over the matcher for all possible matches.
So what you want is a method that you can use in a while loop that will loop through all the matches it can find in the input String. You should look through the API for Matcher to see which method you should use.