给定一个字符串s,一个短字符串t在s中出现多次,需要将多个t中间的字符按顺序打印出来;
例:s = xxxxxabcqwertyuiocxabc1234fgtabcqq
t = abc
打印:qwertyuiocx1234fgt;
String str = "xxxxxabcqwertyuiocxabc1234fgtabcqq";//总串
String temp = "abc";//子串
int firstIndex = str.indexOf(temp);//获取第一个子串的下标
int lastIndex = str.lastIndexOf(temp);//获取最后一个子串的下标
String str1 = str.substring(firstIndex+temp.length(),lastIndex);//截取子串之间的字符
str1 = str1.replace(temp,"");//将中间的子串替换为空子串
System.out.println(str1);