首页 > 开发 > Asp > 正文

asp自动补全html标签自动闭合(正则表达式)

2020-06-20 13:59:56
字体:
来源:转载
供稿:网友
复制代码 代码如下:

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标签只保留文字
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表