您的位置:首页 > Web前端 > HTML

[VB.NET]求一个正则表达式处理一下html

2008-12-29 22:09 369 查看



<script type="text/javascript"><!--
google_ad_client = "pub-8333940862668978";
/* 728x90, 创建于 08-11-30 */
google_ad_slot = "4485230109";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

求一个正则表达式处理一下html
想去除html中除链接标记之外的所有标记,即字符串中遇到象 <...> 这样的部分,如果其中包含href或/a则保留,其余删除。
我原来是这么写的:
For Each m As Match In Regex.Matches(ss, <[^> ]*> , egexOptions.IgnoreCase)
If InStr(LCase(m.Value), href ) < 1 AndAlso LCase(m.Value) <> then
ss = Replace(ss, m.Value, )
End If
Next
不过我觉得这么作可能效率比较低,希望能通过一条正则表达式搞定。
__________________________________________________________________________
up
__________________________________________________________________________
顶顶...
__________________________________________________________________________
何必呢,那不会取出所有的 标签,而不是去除所有不是 的标签.
__________________________________________________________________________
我就是要去除所有不是 的标签
__________________________________________________________________________
我的意思是,用正则表达式,取出所有是 的内容.
__________________________________________________________________________
try

<(?!(a/s|/a> ))[^> ]*?>
__________________________________________________________________________
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息