/*** * 计算字符串在某串中出现的次数 * @param source 某串 * @param word 计算次数的字符 * @return */ public static int getWordCount(String source, String word) { int count = 0; int start; while ((start = source.indexOf(word)) != -1) { count++; source = source.substring(start + word.length()); } return count; }
字符串出现的次数
最新推荐文章于 2023-05-06 22:28:18 发布