string relpacestr(string str, string oldVal, string newVal) { for(string::size_type pos(0); pos!=string::npos; pos += newVal.length()) { pos=str.find(oldVal,pos); if( pos !=string::npos ) { str.replace(pos,oldVal.length(), newVal); } else break; } return str; }