日期:2014-05-17 浏览次数:20457 次
string s = "sfsdfaf{A}sfsfdfsf{Z}sfsfsf{X}sfsfsf";
Dictionary<string, string> replaceDict = new Dictionary<string, string>();
replaceDict.Add("{A}", "286");
replaceDict.Add("{Z}", "145");
replaceDict.Add("{X}", "432");
string r = Regex.Replace(s, @"\{[AZX]\}", m => replaceDict[m.Value]);
Response.Write(r);