asp自动补全html标签自动闭合(正则表达式)_ASP教程-查字典教程网
asp自动补全html标签自动闭合(正则表达式)
asp自动补全html标签自动闭合(正则表达式)
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:FunctioncloseHTML(strContent)DimarrTags,i,OpenPos,ClosePos,re...

复制代码 代码如下:

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

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新ASP教程学习
    热门ASP教程学习
    编程开发子分类