首页
Java
登录
6mi
u
盘
搜
搜 索
Java
正则表达式统计字符串出现次数
正则表达式统计字符串出现次数
xiaoxiao
2026-08-08
8
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); }
转载请注明原文地址: https://www.6miu.com/read-5050882.html
Java
最新回复
(
0
)