private 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;
}
得到指定字符在字符串的位置
最新推荐文章于 2023-03-03 09:12:49 发布