替换字符串我有一个存放字符串变量,让我们这样说:与字符串格式
string str = "https://stackoverflow.com/a/b/1/cdd/d.jpg"
我有字符串格式,可以这样说:
string frmt = "https://stackoverflow.com/a/b/{0}/be/"
现在,我想用frmt替换str中的字符,类似这样的:
string newstr = str.Replace(frmt);
//result should be: /a/b/1/be/d.jpg
Do .net框架有类似的东西?如何轻松完成?
谢谢。
所以要合并两个字符串? – Vercas
否,str的格式为“/ [string1]/[string2]/[string3]/[string4]/[string5]”,string1,2,3和5保持不变,只有string4变化,知道string1和2 .. – Nir