日期:2014-05-17 浏览次数:20442 次
void Main() { string yourhtml="<a href=\"a.aspx?m=10&n=8\">例子</a>"; yourhtml=Regex.Replace(yourhtml,@"(?i)(?<=<a\shref=(['""]?))(\w+)\.aspx(\?[^?'""]+)?(?=\1)", delegate(Match m){return string.Format("{0}.html",m.Groups[2].Value+m.Groups[3].Value.Replace("&","_").Replace("?","_").Replace("=",""));}); Console.WriteLine(yourhtml); }