1. 程式人生 > >c++字串批量替換

c++字串批量替換

void Replace()
{
	offindex = s1.find("wbm",0);
	while( offindex != string::npos )
	{
		cout<<"offindex:"<<offindex<<endl;
		s1.replace(offindex,3,"WBM");
		offindex +=1;
		offindex = s1.find("wbm",offindex);
	}
	cout<<s1<<endl;
}