濮阳杆衣贸易有限公司

主頁 > 知識庫 > asp之自動閉合HTML/ubb標簽函數附簡單注釋

asp之自動閉合HTML/ubb標簽函數附簡單注釋

熱門標簽:地圖標注宅基地 西寧公司外呼系統(tǒng)平臺 騰訊地圖標注商戶關閉 外呼系統(tǒng)還用卡么 徐州人工智能電銷機器人好用嗎 地圖標注服務哪家好 武漢營銷電話機器人軟件 智能電銷機器人適用于哪些行業(yè) 長沙防封電銷卡品牌
Function closeUBB(strContent)
'*************************************
'自動閉合UBB
'*************************************
Dim arrTags, i, OpenPos, ClosePos, re, strMatchs, j, Match
Set re = New RegExp '申明re對象
re.IgnoreCase = True '設置是否區(qū)分字符大小寫
re.Global = True '設置全局可用性
arrTags = Array("code", "quote", "list", "color", "align", "font", "size", "b", "i", "u", "html") '建立數組,存儲相關需要檢測是否閉合的標簽
For i = 0 To UBound(arrTags) '循環(huán)對數組里的每一個元素進行檢測
OpenPos = 0 '初始化當前標簽開始標記的個數
ClosePos = 0 '初始化當前標簽結束標記的個數
re.Pattern = "\[" + arrTags(i) + "(=[^\[\]]+|)\]" '開始分別正則判斷開始與結束標記的個數
Set strMatchs = re.Execute(strContent)
For Each Match in strMatchs
OpenPosOpenPos = OpenPos + 1
Next
re.Pattern = "\[/" + arrTags(i) + "\]"
Set strMatchs = re.Execute(strContent)
For Each Match in strMatchs
ClosePosClosePos = ClosePos + 1
Next
For j = 1 To OpenPos - ClosePos '當開始與結束標記數量不一致時,閉合當前標簽
strContentstrContent = strContent + "[/" + arrTags(i) + "]"
Next
Next
closeUBB = strContent
Set re = Nothing
End Function

程序代碼
Function closeHTML(strContent)
'*************************************
'自動閉合HTML
'*************************************
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
OpenPosOpenPos = OpenPos + 1
Next
re.Pattern = "\/" + arrTags(i) + "\&;"
Set strMatchs = re.Execute(strContent)
For Each Match in strMatchs
ClosePosClosePos = ClosePos + 1
Next
For j = 1 To OpenPos - ClosePos
strContentstrContent = strContent + "/" + arrTags(i) + ">"
Next
Next
closeHTML = strContent
Set re = Nothing
End Function
下面的是pjblog的函數代碼,但沒有注釋,學習研究建議參考上面的注釋
復制代碼 代碼如下:

'*************************************
'自動閉合UBB
'*************************************

Function closeUBB(strContent)
Dim arrTags, i, OpenPos, ClosePos, re, strMatchs, j, Match
Set re = New RegExp
re.IgnoreCase = True
re.Global = True
arrTags = Array("code", "quote", "list", "color", "align", "font", "size", "b", "i", "u", "html")
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
closeUBB = strContent
End Function

'*************************************
'自動閉合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
您可能感興趣的文章:
  • PHP實現(xiàn)HTML標簽自動補全代碼
  • asp自動補全html標簽自動閉合(正則表達式)
  • js自動閉合html標簽(自動補全html標記)
  • asp之自動閉合HTML/ubb標簽函數 附簡單注釋
  • php使HTML標簽自動補全閉合函數代碼

標簽:鷹潭 荊門 雅安 巴彥淖爾 通遼 運城 普洱 通化

巨人網絡通訊聲明:本文標題《asp之自動閉合HTML/ubb標簽函數附簡單注釋》,本文關鍵詞  asp,之,自動,閉合,HTML,ubb,;如發(fā)現(xiàn)本文內容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內容系統(tǒng)采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《asp之自動閉合HTML/ubb標簽函數附簡單注釋》相關的同類信息!
  • 本頁收集關于asp之自動閉合HTML/ubb標簽函數附簡單注釋的相關信息資訊供網民參考!
  • 推薦文章
    岢岚县| 江阴市| 磐石市| 洛宁县| 贵港市| 红河县| 元谋县| 大英县| 永兴县| 昭苏县| 河津市| 册亨县| 临澧县| 汉中市| 溧水县| 哈尔滨市| 河池市| 聂拉木县| 南投县| 奇台县| 天津市| 哈尔滨市| 五常市| 榆树市| 和田县| 迁安市| 永胜县| 元阳县| 南木林县| 桦南县| 泰顺县| 泗洪县| 普定县| 靖安县| 于田县| 江陵县| 仪陇县| 三亚市| 独山县| 富平县| 修文县|