- void StringReplace(string &strBase, string strSrc, string strDes)
- {
- string::size_type pos = 0;
- string::size_type srcLen = strSrc.size();
- string::size_type desLen = strDes.size();
- pos=strBase.find(strSrc, pos);
- while ((pos != string::npos))
- {
- strBase.replace(pos, srcLen, strDes);
- pos=strBase.find(strSrc, (pos+desLen));
- }
- }
from:http://blog.csdn.net/lishengwei/article/details/2654575