Asp.Net正则过滤一个div

Asp.Net过滤一对标签,例如div、ul、p、li、span等

html = “html page”;
Regex regPage = new Regex(@"(?is)<div\sclass=""pages"">((?<Open><div>)|(?<-Open></div>)|.*?)*?(?(Open)(?!))</div>", RegexOptions.IgnoreCase);
html = regPage.Replace(html, "");

 正则过滤url

string str = "我是http://www.baidu.com一个http://1.www.360.cn好人libai.com,http://www.baidu.com/djfkdfj.html?df=sdfs我爱电视xxx.com和电影asdf.sdfsd.sdfsd.com.cn";
string res = Regex.Replace(str, @"(http(s)?://)?[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&$%\$#\=~])*", "");
Response.Write(res);

 

  

posted @ 2016-08-11 10:10  WebApi  阅读(247)  评论(0编辑  收藏  举报
CopyRight © 博客园 WebAPI