public class TotalUtil {
public static int getSum(String text) {
String reg = "^[\u4e00-\u9fa5]{1}$";
int result = 0;
for (int i = 0; i < text.length(); i++) {
String b = Character.toString(text.charAt(i));
if (b.matches(reg)) {
result++;
}
}
return result;
}
}
转载于:https://www.cnblogs.com/mayi1/p/5519570.html