public class Test{
public static void main(String[] args) {
String s="hello jack hello look me to see nohello";
String target="hello";//甚至可以为正则表达式
int count=0;
while(s.indexOf(target)>=0){
s=s.replaceFirst(target, "");
System.out.println(s);
count++;
}
System.out.println(target+" 出现的次数为:"+count);
}
}