How to replace the text between two characters in c#

前端 未结 7 2177
醉梦人生
醉梦人生 2020-12-06 06:24

I am bit confused writing the regex for finding the Text between the two delimiters { } and replace the text with another text in c#,how to replace?

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-06 07:05

    the simplest way is to use split method if you want to avoid any regex .. this is an aproach :

    string s = "sometext {getthis}";
    string result= s.Split(new char[] { '{', '}' })[1];
    

提交回复
热议问题