void str::RemoveStr(string str, string sub)
{
if (str.size() > 0)
{
if (sub.size() == 1)
{
int pos = 0;
while (pos != -1){
pos = str.find(sub);
if( pos == -1 ) break;
else
str.erase(pos, 1);
}
}
else if (sub.size() == 2)
{
int pos = 0;
while (pos != -1){
pos = str.find(sub);
if( pos == -1 ) break;
else
str.erase(pos, 2);
}
}
}
}
一个字符串 删除其中一段字符串
最新推荐文章于 2023-01-06 05:19:13 发布