ASP-based html/UBB tag function closure with simple comments

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.