/** * 判断字符中某一个字段出现的次数 * @param str 字符串 * @param key 字符 * @return 次数 */ public static int getCount(String str,String key){ if(str == null || key == null || "".equals(str.trim()) || "".equals(key.trim())){ return 0; } int count = 0; int index = 0; while((index=str.indexOf(key,index))!=-1){ index = index+key.length(); count++; } return count; }
java判断字符中某一个字段出现的次数
最新推荐文章于 2023-07-05 20:10:12 发布