1 public static void main(String[] args) { 2 String regex="([a-z]{1})(\d{2})"; 3 String candidate = "sdsdx99sdsdc99Supr99erJau99va"; 4 Pattern p=Pattern.compile(regex); 5 Matcher matcher=p.matcher(candidate); 6 while(matcher.find()){ 7 int n=matcher.groupCount(); 8 // for(int i=0;i<=n;i++){ 9 // String str=matcher.group(i); 10 // System.out.println(str); 11 // } 12 13 14 System.out.println(n); 15 } 16 // matcher.reset(); 17 // System.out.println(matcher.group()); 18 // 19 // 20 // System.out.println(matcher.replaceAll("xulu")); 21 22 }