Automatic closed Html/ubb tag function of ASP with simple annotation _ application technique

Source: Internet
Author: User
Function Closeubb (strcontent)
'*************************************
' Auto Close Ubb
'*************************************
Dim arrtags, I, Openpos, Closepos, Re, Strmatchs, J, Match
Set re = New RegExp ' affirm re object
Re. IgnoreCase = True ' Sets whether character case is case-sensitive
Re. Global = True ' Set overall availability
Arrtags = Array ("code", "quote", "list", "Color", "Align", "Font", "Size", "B", "I", "U", "html") ' Set up an array, storage related need to detect whether the closed label
For i = 0 to UBound (arrtags) ' loops each element in the array for detection
Openpos = 0 ' Initializes the number of current tag start tags
Closepos = 0 ' Initializes the number of current tag end tags
Re. Pattern = "\[" + arrtags (i) + "(=[^\[\]]+|) \] "' Start to judge the number of start and end tags separately
Set Strmatchs = Re. Execute (strcontent)
For the Match in Strmatchs
Openposopenpos = Openpos + 1
Next
Re. Pattern = "\[/" + arrtags (i) + "\]"
Set Strmatchs = Re. Execute (strcontent)
For the Match in Strmatchs
Closeposclosepos = Closepos + 1
Next
For j = 1 to Openpos-closepos ' when the start and end tag numbers are inconsistent, close the current label
Strcontentstrcontent = strcontent + "[/" + arrtags (i) + "]"
Next
Next
Closeubb = strcontent
Set re = Nothing
End Function

Program code
Function closehtml (strcontent)
'*************************************
' Auto-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 the Match in Strmatchs
Openposopenpos = Openpos + 1
Next
Re. Pattern = "\</" + arrtags (i) + "\>"
Set Strmatchs = Re. Execute (strcontent)
For the 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, study suggestions refer to the above comments
Copy Code code as follows:

'*************************************
' Auto Close 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 the Match in Strmatchs
Openpos = Openpos + 1
Next
Re. Pattern = "\[/" + arrtags (i) + "\]"
Set Strmatchs = Re. Execute (strcontent)
For the Match in Strmatchs
Closepos = Closepos + 1
Next
For j = 1 to Openpos-closepos
Strcontent = strcontent + "[/" + arrtags (i) + "]"
Next
Next
Closeubb = strcontent
End Function

'*************************************
' Auto-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 the Match in Strmatchs
Openpos = Openpos + 1
Next
Re. Pattern = "\</" + arrtags (i) + "\>"
Set Strmatchs = Re. Execute (strcontent)
For the Match in Strmatchs
Closepos = Closepos + 1
Next
For j = 1 to Openpos-closepos
Strcontent = strcontent + "</" + arrtags (i) + ">"
Next
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.