http://www.netqu.com 中华技术网会员 wuxuehui 发布
/*
作者:何志强[hhzqq@21cn.com]
日期:2000-07-25
功能:字符串替换
*/
package pipi.string;
public final class Replace{
public static java.lang.String replace(java.lang.String strSource,java.lang.String strFrom,java.lang.String strTo){
java.lang.String strDest = "";
int intFromLen = strFrom.length();
int intPos;
while((intPos=strSource.indexOf(strFrom))!=-1){
strDest = strDest + strSource.substring(0,intPos);
strDest = strDest + strTo;
strSource = strSource.substring(intPos+intFromLen);
}
strDest = strDest + strSource;
return strDest;
}
}
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/