public static int strAppearTimes(String regex, String replacement) { if (regex == null || replacement == null) { return 0; } else { if (replacement.length() == 0 || regex.length() < replacement.length()) { return 0; } return (regex.length() - regex.replace(replacement, "").length()) / replacement.length(); } }
获取字符串中某字符出现个数
最新推荐文章于 2023-11-21 17:20:47 发布