/**
* 获取指定字符串出现的次数
*
* @param srcText 源字符串
* @param findText 要查找的字符串
* @return
*/
public static List<Integer> appearNumber(String srcText, String findText) {
int count = 0;
List list = new ArrayList();
Pattern p = Pattern.compile(findText);
Matcher m = p.matcher(srcText);
while (m.find()) {
count++;
int i = m.start();
if (count == 1) {
list.add(i);
}
}
list.add(count);
return list;
}
获取指定字符串出现的次数
于 2022-04-12 13:33:51 首次发布