code: public static Iterator iterator(final Matcher matcher) {
          matcher.reset();
          return new Iterator() {
              private boolean found /* = false */;
              private boolean done /* = false */;
  
              public boolean hasNext() {
                  if (done) {
                      return false;
                  }
                  if (!found) {
                      found = matcher.find();
                      if (!found) {
                          done = true;
                      }
                  }
                  return found;
              }
  
              public Object next() {
                  if (!found) {
                      if (!hasNext()) {
                          throw new NoSuchElementException();
                      }
                  }
                  found = false;
  
                  if (hasGroup(matcher)) {
                      // are we using groups?
                      // yes, so return the specified group as list
                      List<String> list = new ArrayList<String>(matcher.groupCount());
                      for (int i = 0; i <= matcher.groupCount(); i++) {
                         list.add(matcher.group(i));
                      }
                      return list;
                  } else {
                      // not using groups, so return the nth
                      // occurrence of the pattern
                      return matcher.group();
                   }
              }
  
              public void remove() {
                  throw new UnsupportedOperationException();
              }
          };
      }
docs: Returns an {@link java.util.Iterator} which traverses each match.
  
  @param matcher a Matcher object
  @return an Iterator for a Matcher
  @see java.util.regex.Matcher#group()
  @since 1.0