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; } }
时间: 2024-10-02 06:10:19