日期:2014-05-17 浏览次数:20437 次
string[] strarray = new string[] { @"<loc>/Help/List-0018,0019.shtml</loc> ",@"<loc>/Help/About Us.html</loc>"}; string[] Replacestr = new string[] { @"http://abc.sina.com.cn ",@"http://www.sohu.com"}; List<string> list = new List<string>(); foreach (string s in strarray) { if (s.Contains(".shtml") || s.Contains(".aspx")) { string lstr = System.Text.RegularExpressions.Regex.Replace(s, @"(?<=<loc>).*?(?=/Help)", Replacestr[0]); list.Add(lstr); } if (s.Contains(".html") || s.Contains(".htm")) { string lstr = System.Text.RegularExpressions.Regex.Replace(s, @"(?<=<loc>).*?(?=/Help)", Replacestr[1]); list.Add(lstr); } } list.ForEach(x => Response.Write(x));