700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > c# 正则表达式 html标签 C#匹配HTML标签 正则表达式谁会?

c# 正则表达式 html标签 C#匹配HTML标签 正则表达式谁会?

时间:2018-10-27 01:32:05

相关推荐

c# 正则表达式 html标签 C#匹配HTML标签 正则表达式谁会?

米脂

JS:function StripHtml(html){var scriptregex = ".]*>[sS]*?";var scripts = new RegExp(scriptregex, "gim");html = html.replace(scripts, " ");//Stripts the ";var styles = new RegExp(styleregex , "gim");html = html.replace(styles, " ");//Strips the HTML tags from the htmlvar objRegExp = new RegExp("", "gim");var strOutput = html.replace(objRegExp, " ");//Replace all < and > with < and >strOutput = strOutput.replace(/, "/, ">");objRegExp = null;return strOutput;}.NET:过滤不安全的HTML代码[AjaxPro.AjaxMethod()]public String UnSafeHTMLFilter(string html){Regex regex1 = new Regex(@"标记html = regex2.Replace(html, ""); //过滤href=javascript: () 属性html = regex3.Replace(html, " _disibledevent="); //过滤其它控件的on...事件html = regex4.Replace(html, ""); //过滤iframehtml = regex5.Replace(html, ""); //过滤framesetreturn html;}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。