Function closeubb (strcontent)
'*************************************
'Automatically closes UBB
'*************************************
Dim arrtags, I, openpos, closepos, re, strmatchs, J, match
Set Re = new Regexp 'declares the re object
Re. ignorecase = true': Specifies whether to distinguish between uppercase and lowercase characters.
Re. Global = true' sets global availability
Arrtags = array ("code", "quote", "list", "color", "align", "font", "size", "B", "I ", "U", "html") 'creates an array to store related tags that need to be checked for closure
For I = 0 to ubound (arrtags) 'checks each element in the logarithm group cyclically.
Openpos = 0' initialize the number of tags starting with the current tag
Closepos = 0' initializes the number of end tags of the current tag
Re. pattern = "\ [" + arrtags (I) + "(= [^ \ [\] + |) \]" 'start to judge the number of start and end tags respectively
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' when the number of start and end tags is inconsistent, close the current tag
Strcontentstrcontent = strcontent + "[/" + arrtags (I) + "]"
Next
Next
Closeubb = strcontent
Set Re = nothing
End Function
Program Code
Function closehtml (strcontent)
'*************************************
'Automatically close 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
The following is the pjblog function code, but there is no comment. For more information, see the above comment. Copy code The Code is as follows: '*************************************
'Automatically closes 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
'*************************************
'Automatically close 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 = "\ "
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
closehtml = strcontent
end function