http://www.cnblogs.com/lin714115/archive/2010/09/25/1834690.html
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* @author ZJB
*/
public class App {
public static void main(String[] args) {
Pattern pattern = Pattern.compile("(\\{\\d+\\})");
Matcher matcher = pattern.matcher("aaa{0}bbb{1} vv 555{2}, a 7 {3}.{4} {5}uuooo{6}{7}");
System.out.println(matcher.groupCount());
List<String> list = new ArrayList<>();
while(matcher.find()) {
System.out.println(matcher.group(0));
list.add(matcher.group(0));
}
System.out.println(list.size());
}
}