过滤、替换
来源:互联网 发布:手机淘宝1元秒杀在哪里 编辑:程序博客网 时间:2024/05/05 10:21
string str2 = FilterHtml(this.TextBox1.Text.ToString());
this.TextBox2.Text = str.Replace("1\r\n 楼", "LOVE");
Regex regex = new Regex("1[1\\S|\\s]*楼");
string a = regex.Replace(this.TextBox1.Text.ToString(), "1楼");
b = this.TextBox1.Text.ToString();
Regex regex = new Regex("{n}[\\S|\\s]*楼");
b = regex.Replace(b, "31");
public static string FilterHtml(string input)
{
if (input == null || input == "")
return input;
input = input.Replace("&", "&");
input = input.Replace("<", "<");
input = input.Replace(">", ">");
input = input.Replace(" ", " ");
//input = input.Replace("'", "'");
input = input.Replace("\\", """);
input = input.Replace("\r\n", "<br>\r\n");
return input;
}
public string checkStr(string html)
{
System.Text.RegularExpressions.Regex regex1 = new System.Text.RegularExpressions.Regex(@"<script[\s\S]+</script *>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex2 = new System.Text.RegularExpressions.Regex(@" href *= *[\s\S]*script *:", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex3 = new System.Text.RegularExpressions.Regex(@" no[\s\S]*=", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex4 = new System.Text.RegularExpressions.Regex(@"<iframe[\s\S]+</iframe *>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex5 = new System.Text.RegularExpressions.Regex(@"<frameset[\s\S]+</frameset *>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex6 = new System.Text.RegularExpressions.Regex(@"\<img[^\>]+\>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex7 = new System.Text.RegularExpressions.Regex(@"</p>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex8 = new System.Text.RegularExpressions.Regex(@"<p>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex9 = new System.Text.RegularExpressions.Regex(@"<[^>]*>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
html = regex1.Replace(html, ""); //过滤<script></script>标记
html = regex2.Replace(html, ""); //过滤href=javascript: (<A>) 属性
html = regex3.Replace(html, " _disibledevent="); //过滤其它控件的on...事件
html = regex4.Replace(html, ""); //过滤iframe
html = regex5.Replace(html, ""); //过滤frameset
html = regex6.Replace(html, ""); //过滤frameset
html = regex7.Replace(html, ""); //过滤frameset
html = regex8.Replace(html, ""); //过滤frameset
html = regex9.Replace(html, "");
html = html.Replace(" ", "");
html = html.Replace("</strong>", "");
html = html.Replace("<strong>", "");
return html;
}
- 过滤、替换
- 过滤字符替换成*号
- 字符的过滤和替换
- java过滤敏感词替换**
- 过滤、替换、转义、验证函数
- 过滤html标签并替换
- java关键字敏感字实现过滤替换
- DFA算法过滤敏感词,替换为*
- java过滤或替换html标签
- 过滤字段,查找替换(学习笔记)
- php过滤替换特殊字符 函数
- DFA算法过滤敏感词,替换为*
- DEDE采集规则过滤与替换
- Swift 字符串替换/过滤/切割/拼接
- 对于字符串替换或过滤一些字符
- asp。met 2.0 字符替换,过滤简单操作
- drupal6中使用drupal_html_to_text方法过滤替换html超文本代码
- 替换的代码,在过滤敏感的词有用
- 各鍵對應的ASCII值.保存下,隨時用的上
- sql2000无法打开1433端口及解决方法
- 定位的第一个中实现 ,用 criter类实现 的职位选择
- C++连接mysql的方法
- 获取标准程序的BADI,用户出口,增强
- 过滤、替换
- Eclipse快捷键大全
- micro2440利用LEDS与BUTTONS驱动实现按键控制led灯【开发总结】
- AX-Explor系列电子物证现场勘查箱
- window.open和window.location.href的几种用法
- Struts2获取request的
- crontab及每15分钟同步服务器的时间
- 添加本地通知事件
- 常用oracle语句