å¯ä»¥ä½¿ç¨æ£å表达å¼+ä¸æå符ç¼ç åºé´éªè¯ä¸ä¸ªå符串ä¸æ¯å¦å
å«æ±å
代ç å¦ä¸ï¼
public static void main(String[] args) {
int count = 0;
String regEx = "[\\u4e00-\\u9fa5]";
//System.out.println(regEx);
String str = "ä¸æfdas ";
//System.out.println(str);
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(str);
while (m.find()) {
for (int i = 0; i <= m.groupCount(); i++) {
count = count + 1;
}
}
System.out.println("å
±æ " + count + "个 ");
}
温馨提示:内容为网友见解,仅供参考