復制代碼 代碼如下:
Function closeHTML(strContent)
Dim arrTags, i, OpenPos, ClosePos, re, strMatchs, j, Match
Set re = New RegExp
re.IgnoreCase = True
re.Global = True
arrTags = Array("p", "div", "span", "table", "ul", "font", "b", "u", "i", "h1", "h2", "h3", "h4", "h5", "h6")
For i = 0 To UBound(arrTags)
OpenPos = 0
ClosePos = 0
re.Pattern = "\" + arrTags(i) + "( [^\\>]+|)\&;"
Set strMatchs = re.Execute(strContent)
For Each Match in strMatchs
OpenPos = OpenPos + 1
Next
re.Pattern = "\/" + arrTags(i) + "\&;"
Set strMatchs = re.Execute(strContent)
For Each Match in strMatchs
ClosePos = ClosePos + 1
Next
For j = 1 To OpenPos - ClosePos
strContent = strContent + "/" + arrTags(i) + ">"
Next
Next
closeHTML = strContent
End Function
您可能感興趣的文章:- php過濾HTML標簽、屬性等正則表達式匯總
- asp.net正則表達式刪除指定的HTML標簽的代碼
- Java/Js下使用正則表達式匹配嵌套Html標簽
- 移除HTML標簽的正則表達式
- 用正則表達式格式化html標簽的代碼
- 請教一個正則表達式,匹配所有Html標簽外部的指定字符串
- 使用正則表達式去除所有html標簽只保留文字