How do I replace part of a string in C#?

前端 未结 5 904
旧时难觅i
旧时难觅i 2020-12-10 20:40

Supposed I have the following string:

string str = \"text\";

And I would like to change \'tag\' to \'newTag\' so the

5条回答
  •  醉酒成梦
    2020-12-10 21:05

    Why use regex when you can do:

    string newstr = str.Replace("tag", "newtag");
    

    or

    string newstr = str.Replace("","").Replace("","");
    

    Edited to @RaYell's comment

提交回复
热议问题