Asp.NET Tutorials
Home > 正则表达式 > 如何过滤掉html字符(c#)
如何过滤掉html字符(c#)

<%@Page Language="c#" Debug="true"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="gb2312" lang="gb2312">
<head>
<title> New Document </title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="title" content="" />
<meta name="subject" content="" />
<meta name="language" content="gb2312" />
<meta content="all" name="robots" />
<meta name="Author" content="活靶子" />
<meta name="Copyright" content="www.AspxBoy.Com,自由版权,任意转载." />
<meta name="Description" content="www.AspxBoy.Com" />
<meta name="Keywords" content="www.AspxBoy.Com,活靶子,huobazi" />
<script langauge="c#" runat="server">
   
 void Page_Load(object o , EventArgs e)
 {
 
  if(!Page.IsPostBack)
  {
   string s = @"<span class='lframe-t-text'>今日<font color='red'>热门新闻</font></span><div>adfadf</div>";
   s = System.Text.RegularExpressions.Regex.Replace(s,"<[^>]+>","");
   Response.Write(s);
  }
  
 }

</script>
</head>
<body>
<form id="frm" runat="server">

 

</form>
</body>
</html>

Add by : Huobazi (2005-6-16:03:46)