CSDN博客

img flyying

replace

发表于2004/10/18 11:06:00  348人阅读

package zpxx;
public class replace{
public String rce(String parentStr,String ch,String rep)
{
int i = parentStr.indexOf(ch);
StringBuffer sb = new StringBuffer();
if (i == -1){
 return parentStr;
}
 sb.append(parentStr.substring(0,i) + rep);
if (i+ch.length() < parentStr.length()) {
sb.append(rce(parentStr.substring(i+ch.length(),parentStr.length()),ch,rep));
}
return sb.toString();
}
}
阅读全文
0 0

相关文章推荐

img
取 消
img