字符串替换,string的强大
2011-06-13 07:38
127 查看
#include"iostream"
#include"string"
using namespace std;
int main()
{
string str;
while(getline(cin,str))
{
string::size_type k;
while((k=str.find("you"))!=string::npos){
str.replace(k,3,"we");
}
cout<<str<<endl;
}
return 0;
}
#include"string"
using namespace std;
int main()
{
string str;
while(getline(cin,str))
{
string::size_type k;
while((k=str.find("you"))!=string::npos){
str.replace(k,3,"we");
}
cout<<str<<endl;
}
return 0;
}
相关文章推荐
- std::string字符串中替换子串的函数
- 黄聪:Python 字符串操作(string替换、删除、截取、复制、连接、比较、查找、包含、大小写转换、分割等)
- java String字符串替换
- c++的字符串char与string相互转化,以及string的,切割,替换字符,字符串拼接方法(object向c++转型系列教程2)
- Python 字符串操作(string替换、删除、截取、复制、连接、比较、查找、包含、大小写转换、分割等)
- Python 字符串操作(string替换、删除、截取、复制、连接、比较、查找、包含、大小写转换、分割等)
- String字符串操作--切割,截取,替换,查找,比较,去空格.....
- java string 字符串替换
- 黄聪:Python 字符串操作(string替换、删除、截取、复制、连接、比较、查找、包含、大小写转换、分割等)
- Python 字符串操作(string替换、删除、截取、复制、连接、比较、查找、包含、大小写转换、分割等)
- Java替换字符串中的“\"”的处理方法(String.replaceAll的源码分析)
- 黄聪:Python 字符串操作(string替换、删除、截取、复制、连接、比较、查找、包含、大小写转换、分割等)
- string替换所有指定字符串(C++)
- Python 字符串操作(string替换、删除、截取、复制、连接、比较、查找、包含、大小写转换、分割等)
- java中String字符串的替换函数:replace与replaceAll的区别
- Lua 字符串替换函数 string.gsub(s, pat, repl [, n])
- python中用string.maketrans和translate巧妙替换字符串
- Lua 字符串替换函数 string.gsub(s, pat,
- Python 字符串操作(string替换、删除、截取、复制、连接、比较、查找、包含、大小写转换、分割等)
- string替换所有指定字符串(C++)