asp自动补全html标签自动闭合(正则表达式)
代码如下:
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
相关推荐
wangzhaotongalex 2020-10-20
wyq 2020-11-11
TLROJE 2020-10-26
风雨断肠人 2020-10-13
duanqingfeng 2020-09-29
rechanel 2020-11-16
cshanzhizi 2020-10-16
luofuIT成长记录 2020-09-22
phphub 2020-09-10
taomengxing 2020-09-07
MaggieRose 2020-08-19
flyingssky 2020-08-18
山水沐光 2020-08-18
jyj00 2020-08-15
AHuqihua 2020-08-09
山水沐光 2020-08-03