字符串匹配所有子串坐标

来源:互联网 发布:数据研发工程师 编辑:程序博客网 时间:2024/05/17 06:10
private List<Integer> getAllIndex(String content,String groupf) {  List<Integer> res = new ArrayList<Integer>();  //记录位置  Integer index;  //需要匹配的次数  String[] split = content.split(groupf);  if(split.length>2){    index = content.indexOf(groupf);    res.add(index);    for (int i= 0;i<split.length-2 ;i++){      index = content.indexOf(groupf,index+groupf.length());      res.add(index);    }  }else{    index = content.indexOf(groupf);    res.add(index);  }  return res;}
原创粉丝点击