求助!输入一段字符的查找并替换
我本初学者
想用控制台程序编写一个字符查找并替换的程序,不知该从何下手求助~~
例:
输入一段字符:i am now in usa , i found the usa is not for me , the usa is too bad ! because in the usa i can not say chinese !
然后我想查找字符‘usa’并且把所有的‘usa’替换成‘the beautiful usa’。
请问如何实现?
有代码更好啦
[解决办法]
str=str.Replace("usa","the beautiful usa");
[解决办法]
str=str.Replace(@"usa",@"the beautiful usa");
这就是答案
[解决办法]
正解,不用遍历什么的,有实现好的方法了