ASP's UBB function (recommended) _ Regular expression

Source: Internet
Author: User
Tags chr
Copy Code code as follows:

function unhtml (content)
Unhtml=content
If content <> "" Then
Unhtml=replace (unhtml, "&", "&")
Unhtml=replace (unhtml, "<", "<")
Unhtml=replace (unhtml, ">", ">")
Unhtml=replace (UNHTML,CHR (34), "" ")
Unhtml=replace (UNHTML,CHR), "<br>"
Unhtml=replace (UNHTML,CHR (32), "")
' Unhtml=ubb (unhtml)
End If
End Function

function Ubb (content)
Dim Nowtime,i
Ubb=content
Nowtime=now ()
Ubb=convert (UBB, "code")
Ubb=convert (UBB, "html")
Ubb=convert (UBB, "url")
Ubb=convert (UBB, "color")
Ubb=convert (UBB, "font")
Ubb=convert (UBB, "size")
Ubb=convert (UBB, "quote")
Ubb=convert (UBB, "email")
Ubb=convert (UBB, "img")
Ubb=convert (UBB, "SWF")

Ubb=autourl (UBB)
Ubb=replace (UBB, "[b]", "<b>", 1,-1,1)
Ubb=replace (UBB, "[/b]", "</b>", 1,-1,1)
Ubb=replace (UBB, "[I]", "<i>", 1,-1,1)
Ubb=replace (UBB, "[I]", "</i>", 1,-1,1)
Ubb=replace (UBB, "[U]", "<u>", 1,-1,1)
Ubb=replace (UBB, "[/U]", "</u>", 1,-1,1)
Ubb=replace (UBB, "[Blue]", "<font color= ' #000099 ' >", 1,-1,1)
Ubb=replace (UBB, "[/blue]", "</font>", 1,-1,1)
Ubb=replace (UBB, "[Red]", "<font color= ' #990000 ' >", 1,-1,1)
Ubb=replace (UBB, "[/red]", "</font>", 1,-1,1)
For I=1 to 28
Ubb=replace (Ubb, "{: Em" &i& "}", "</img>", 1,6,1)
Ubb=replace (Ubb, "{: Em" &i& "}", "", 1,-1,1)
Next
Ubb=replace (UBB, "[" &AMP;CHR (176), "[", 1,-1,1)
Ubb=replace (UBB,CHR (176) & "]", "]", 1,-1,1)
Ubb=replace (UBB, "/" &AMP;CHR (176), "/", 1,-1,1)
' Ubb=replace (Ubb, "{; Em", "{: Em", 1,-1,1)
End Function


function Convert (UBB,COVT)
Dim Ctext,startubb,endubb,lcovt,text,codetext
Ctext=ubb
Startubb=1
Do while covt= "url" or covt= "color" or covt= "font" or covt= "size"
Startubb=instr (Startubb,ctext, "[" &CovT& "=", 1)
If Startubb=0 then Exit Do
Endubb=instr (Startubb,ctext, "]", 1)
If Endubb=0 then Exit Do
Lcovt=covt
Startubb=startubb+len (LCOVT) +2
Text=mid (Ctext,startubb,endubb-startubb)
Codetext=replace (Text, "[", "[" &AMP;CHR (176), 1,-1,1)
Codetext=replace (Codetext, "]", Chr (176) & "]", 1,-1,1)
' Codetext=replace (Codetext, "{: Em", "{; Em", 1,-1,1)
Codetext=replace (Codetext, "/", "/" &AMP;CHR (176), 1,-1,1)
Select Case Covt
Case "COLOR"
Ctext=replace (Ctext, "[color=" &text& "]", "<font color= '" &text& "' >", 1,1,1)
Ctext=replace (Ctext, "[/color]", "</font>", 1,1,1)
Case "Font"
Ctext=replace (Ctext, "&text&"] "," <font face= ' "&text&" ' > ", 1,1,1)
Ctext=replace (Ctext, "[/font]", "</font>", 1,1,1)
Case "Size"
If IsNumeric (text) Then
If Text>6 then text=6
If Text<1 then text=1
Ctext=replace (Ctext, "[size=" &text& "]", "<font size= '" &text& "' >", 1,1,1)
Ctext=replace (Ctext, "[/size]", "</font>", 1,1,1)
End If
Case "url"
Ctext=replace (Ctext, "[Url=" &text& "]", "<a href=" "&codetext&" ' target=_blank> ", 1,1,1)
Ctext=replace (Ctext, "[/url]", "</a>", 1,1,1)
Case "Email"
Ctext=replace (Ctext, "[" &CovT& "=" &text& "]", "<a Href=mailto:" &text& ">", 1,1,1)
Ctext=replace (Ctext, "[/" &CovT& "]", "</a>", 1,1,1)
End Select
Loop

Startubb=1
Todo
Startubb=instr (Startubb,ctext, "[" &CovT&] ", 1)
If Startubb=0 then Exit Do
Endubb=instr (Startubb,ctext, "[/" &CovT&] ", 1)
If Endubb=0 then Exit Do
Lcovt=covt
Startubb=startubb+len (LCOVT) +2
Text=mid (Ctext,startubb,endubb-startubb)
Codetext=replace (Text, "[", "[" &AMP;CHR (176), 1,-1,1)
Codetext=replace (Codetext, "]", Chr (176) & "]", 1,-1,1)
' Codetext=replace (Codetext, "{: Em", "{; Em", 1,-1,1)
Codetext=replace (Codetext, "/", "/" &AMP;CHR (176), 1,-1,1)
Select Case Covt
Case "url"
Ctext=replace (Ctext, "[" &CovT& "]" &text, "<a href= '" &codetext& "' Target=_blank>" & codetext,1,1,1)
Ctext=replace (Ctext, "<a href= '" &codetext& "' target=_blank>" &codetext& "[/" &CovT& "]" , "<a href=" &codetext& "target=_blank>" &codetext& "</a>", 1,1,1)
Case "Email"
Ctext=replace (Ctext, "[" &CovT& "]", "<a Href=mailto:" &text& ">", 1,1,1)
Ctext=replace (Ctext, "[/" &CovT& "]", "</a>", 1,1,1)
Case "HTML"
Codetext=replace (Codetext, "<br>", Chr (13), 1,-1,1)
Codetext=replace (Codetext, "", Chr (32), 1,-1,1)
Randomize
Rid= "Temp" &int (100000 * Rnd)
Ctext=replace (Ctext, "{html}" &text, "code snippet is as follows: <textarea id=" &rid& "rows=15 style=" width:100% ' class= ' " BK ' > ' &codetext,1,1,1)
Ctext=replace (Ctext, "code snippet as follows: <textarea id=" &rid& "rows=15 style= ' width:100% ' class= '" BK ' > "& codetext& "{/html}", "code snippet is as follows: <textarea id=" &rid& "rows=15 style= ' width:100% ' class= ' ' bk ' > ' & codetext& "</textarea><input Onclick=runex ('" &rid& ") Type=button value= Run this section of code Name=button1 class= ' Tips_bo ' > <input onclick=jm_cc (' &rid& ') Type=button value= copy to my clipboard name=button2 class= ' Tips_ Bo ' > ', 1,1,1)
Case "IMG"
Ctext=replace (Ctext, "[img]" &text, "<a href=" &AMP;CHR (a) & "About: "&AMP;CHR &" Target=_blank>Ctext=replace (Ctext, "[/IMG]", "vspace=2 hspace=2 border=0 alt=:: Click on the picture to open in a new window::></a>", 1,1,1)
Case "Code"
Ctext=replace (Ctext, "[Code]" &text, "The following is the program code &LT;HR noshade>" &codetext,1,1,1)
Ctext=replace (Ctext, "The following is the program code &LT;HR noshade>" &codetext& "[/code]", "The following is program code &LT;HR noshade>" & codetext& "Case "Quote"
Atext=replace (Text, "[img]", "", 1,-1,1)
Atext=replace (Atext, "[/IMG]", "", 1,-1,1)
Atext=replace (Atext, "[SwF]", "", 1,-1,1)
Atext=replace (Atext, "[/swf]", "", 1,-1,1)
Atext=replace (Atext, "{html}", "", 1,-1,1)
Atext=replace (Atext, "{/html}", "", 1,-1,1)
' Atext=replace (Atext, "{: Em", "{; Em", 1,-1,1)
Atext=splitwords (atext,350)
Atext=replace (ATEXT,CHR (32), "", 1,-1,1)
Ctext=replace (Ctext, "[quote]" &text, "<blockquote>Ctext=replace (Ctext, "<blockquote>Case "SWF"
Ctext=replace (Ctext, "[SwF]" &text, "movie Address:<br>" &text& "<br><object classid= ' Clsid:d" 27cdb6e-ae6d-11cf-96b8-444553540000 ' codebase= ' http://download.macromedia.com/pub/shockwave/cabs/flash/ swflash.cab#version=5,0,0,0 ' width= ' height= ' ><param name=movie value= ' "&codetext&" ' >< param name=quality value=high><embed src= ' "&codetext&" ' Quality=high pluginspage= ' http:// Www.macromedia.com/shockwave/download/index.cgi? P1_prod_version=shockwaveflash ' type= ' application/x-shockwave-flash ' width= ' height= ' > ', 1,1,1)
Ctext=replace (Ctext, "<object classid= ' clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 ' codebase= ' http://') download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0 ' width= ' height= ' >< param name=movie value= ' "&codetext&" ' ><param name=quality value=high><embed src= ' "&codetext & "' Quality=high pluginspage= ' http://www.macromedia.com/shockwave/download/index.cgi?" P1_prod_version=shockwaveflash ' type= ' application/x-shockwave-flash ' width= ' height= ' > ' & ' [/swf] ', ' <object classid= ' clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 ' codebase= ' http://download.macromedia.com/pub/ shockwave/cabs/flash/swflash.cab#version=5,0,0,0 ' width= ' height= ' ><param name=movie value= ' "& codetext& "' ><param name=quality value=high><embed src= '" &codetext& "' Quality=high Pluginspage= ' http://www.macromedia.com/shockwave/download/index.cgi? P1_prod_version=shockwaveflash ' type= ' application/x-shockwave-flash ' width= '"Height= ' >" & "</embed></object>", 1,1,1)
End Select
Loop
Convert=ctext
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.