标签:
/**
* 计算关键字在文本中出现的次数
* @param text
* @param key
* @return
*/
public static int count(String text, String key) {
int count = 0, start = 0;
while ((start = text.indexOf(key, start)) >= 0) {
start += key.length();
count++;
}
return count;
}
标签:
原文地址:http://www.cnblogs.com/wikiki/p/5560240.html