正则过滤除了表格标签以外的其他所有html标签

来源:百度知道 编辑:UC知道 时间:2024/07/07 08:07:45
如 <table id="1"> <tr><td> <a>过滤html标签</a></td> </tr></table>
过滤为:
<table><tr><td>过滤html标签</td></tr></table>
table tr 等标签内的属性也不要。
谢谢帮忙!

Function StringWithoutBrackets(ByVal s As String) As String
With CreateObject("VBSCRIPT.REGEXP")
.Global = True
.Pattern = "[<][^>]*[>]"
StringWithoutBrackets = .Replace(s, "")
End With
End Function

这个自定义函数可以解决在VBA中的问题
不知道你用的什么语言,试试下面的正则式
[<][^>]*[>]

补充一点,首先可用SPLIT分离字符,再用这个过滤标签,最后提取表格数据