public static void main(String[] args) {
String str = "中国,美国,日本,朝鲜,中国,中国,美国,越南";
String reg = "中国";
Pattern p = Pattern.compile(reg);
Matcher m = p.matcher(str);
int i = 0;
while(m.find()) {
i++;
}
System.out.println(i);
}
public static void main(String[] args) {
String str = "中国,美国,日本,朝鲜,中国,中国,美国,越南";
String reg = "中国";
Pattern p = Pattern.compile(reg);
Matcher m = p.matcher(str);
int i = 0;
while(m.find()) {
i++;
}
System.out.println(i);
}