去掉html标签方法
程序员文章站
2022-06-21 18:58:38
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(); }
推荐阅读
-
Html5 滚动穿透的方法
-
两个