您的位置:首页 > 其它

判断字符串中有多少个中文的工具类

2014-10-29 15:08 260 查看
public class ChineseNumFromStrUtil {
public static int getChineseNumFromStrUtil(String str) {
int count = 0;
String regEx = "[\\u4e00-\\u9fa5]";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(str);
while (m.find()) {
for (int i = 0; i <= m.groupCount(); i++) {
count = count + 1;
}
}
return count;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: