`
- 浏览:
68120 次
-
1public static string StripHtmlXmlTags(string content)
2 {
3 return Regex.Replace(content, "<[^>]+>", "", RegexOptions.IgnoreCase | RegexOptions.Compiled);
4 }
5
6 去除html标签#region 去除html标签
7
8 // Strip All Tags from a String
9 /**//*
10 * Takes a string and strips all bbcode and html from the
11 * the string. Replacing any <br />s with linebreaks. This
12 * method is meant to be used by ToolTips to present a
13 * a stripped-down version of the post.Body
14 *
15 */
16 /**//// <summary>
17 /// 去除所有html标签
18 /// </summary>
19 /// <param name="stringToStrip"></param>
20 /// <returns></returns>
21 public static string StripAllTags(string stringToStrip)
22 {
23 // paring using RegEx
24 //
25 stringToStrip = Regex.Replace(stringToStrip, "</p(?:\\s*)>(?:\\s*)<p(?:\\s*)>", "\n\n", RegexOptions.IgnoreCase | RegexOptions.Compiled);
26 stringToStrip = Regex.Replace(stringToStrip, "<br(?:\\s*)/>", "\n", RegexOptions.IgnoreCase | RegexOptions.Compiled);
27 stringToStrip = Regex.Replace(stringToStrip, "\"", "''", RegexOptions.IgnoreCase | RegexOptions.Compiled);
28 stringToStrip = StripHtmlXmlTags(stringToStrip);
29 return stringToStrip;
30 }
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
SQl去掉HTML标签函数 彻底防止SQL注入
ASP去除HTML标记的脚本代码,使用正则函数
下面这段代码,不会替换ld”(\>)” str=re.replace(str,” “) re.Pattern=”(\<\/[^\<]*\>)” str=re.replace(str,” “) str=replace(str,” “,””) str=replace(str,” “,””) no...
asp.net下去除html标签的函数。
包括常用过滤html标签、截取字符...过滤html标签函数:如果只是把类似的标记统统去掉,并不需要考虑别的。 截取字符串函数:截取字符串并限制字符串长度,多于给定的长度 获得本页地址:常用用于分页功能,链接地址参数
代码如下:<% ‘/* 函数名称:Zxj_ReplaceHtml ClearHtml ‘/* 函数语言:VBScript Language ‘/* 作 用:清除文件HTML格式函数 ‘/* 传递参数:Content (注:需要进行清除的内容) ‘/* 函数作者:张晓军...
过滤html标签的代码,如果只是把类似的标记统统去掉,并不需要考虑别的
/// /// 去除HTML标记 /// /// ”strHtml”>包括HTML的源码 /// 已经去除后的文字 public static string StripHTML(string strHtml) { string [] aryReg ={ @”[removed]]*?>.*?[removed]”, @”<...
‘****************************** ‘函数:RemoveHTML_A(strText) ‘参数:strText,待处理的字符串 ‘作者:阿里西西 ‘日期:2007/7/12 ‘描述:去除HTML代码中所有标签 ‘示例:<%=RemoveHTML_A(“欢迎...
去掉html中的table代码
代码做的非常简单,只是用于演示,没有加入任何过滤函数。请务必修改(加入过滤函数)后使用,【坚决不能】直接用于网站!! 之前没怎么接触过js,也是随手做一个。如果不满意请各位多包含,毕竟我不是骗分,也请您...
chop执行去除空格处理,get_html_translation_table返回转化列表到变量,定义包括HTML编码的字符串htmlentities,htmlspecialchars_decode 定义包含HTML特殊字符的字符串,nl2br quotemeta rtrim等. 定义和用法:chop() ...
当然,你可以将代码通通copy过来,也许你并不喜欢这样。 例如有这样一个html,里面有一个按钮,当按下时调用b.js文件中的方法b()。而b()中又要调用a.js文件中的方法a()。若要实现这个功能,必须注意,将要引入的Js...
代码如下: [removed] function queryClass(classnames){ var classobj= new Array();//定义数组 var classint=0;//定义数组的下标 var tags=document.getElementsByTagName(“*”);//获取HTML的所有标签 for(var i ...
3、在统计注释行是,程序先是用trim()函数去掉两遍的空格,如何符合以下风格的代码,一律视为注释行: //.............. /*.............. *............... ...............*/ <br>四、...
函数的理解和写一个函数trim()去掉字符串左右空格。 trim()是参照了jquery的源码,你可以放心使用。 对于js中eval()函数的理解是本人心得不一定正确。 代码如下: <!DOCTYPE HTML PUBLIC “-//W3C//DTD ...