public static string CleanHtml(string strHtml) { strHtml = Regex.Replace(strHtml, @"(\)|(\)", "", RegexOptions.IgnoreCase | RegexOptions.Singleline); ... ...
public static string CleanHtml(string strHtml) { strHtml = Regex.Replace(strHtml, @"(\<script(.+?)\</script\>)|(\<style(.+?)\</style\>)", "", RegexOptions.IgnoreCase | RegexOptions.Singleline); //刪除標簽 var r = new Regex(@"</?[^>]*>", RegexOptions.IgnoreCase); Match m; for (m = r.Match(strHtml); m.Success; m = m.NextMatch()) { strHtml = strHtml.Replace(m.Groups[0].ToString(), ""); } return strHtml.Trim(); }