Ubbcode Simple-practical _ regular expressions

Source: Internet
Author: User
Tags chr ftp

<%
function Chkbadwords (fstring)
    if not (IsNull (badwords) or IsNull (fstring)) then
    bwords = Split (Badwords, "|")
    for i = 0 To UBound (bwords)
        fstring = Replace ( Fstring, Bwords (i), String (Len (Bwords (i)), "*")
    next
    chkbadwords = Fstring
    End If
End Function

function HTMLEncode (fstring)
If not IsNull (fstring) then
    ' fstring = Replace (fstring, CHR (), "&")
    ' fstring = replace (fstring, ">", ">")
  & nbsp ' fstring = replace (fstring, <, <)
    ' fstring = replace (fstring, CHR (), "'")
 & nbsp;  ' fstring = replace (fstring, CHR (), " ")
    ' fstring = replace (fstring, CHR (34), "" ")
    ' fstring = replace (fstring, CHR ()," ")
    fstring = replace (fstring, CHR ( "<br/>")
    HTMLEncode = fstring
End If
End Function

function Htmlcode (fstring)
If not IsNull (fstring) then
    fstring = Replace (fstring, CHR (), "")
    fstring = replace (fstring, CHR (a), "<br/>")
     Htmlcode = fstring
End If
End Function
function HtmlDecode (fstring)
If not IsNull (fstring) Then
    ' fstring = replace (fstring, CHR (pdf), "&")
    ' fstring = replace ( Fstring, ">", ">")
    ' fstring = replace (fstring, "<", "<")
    ' fstring = replace (fstring, CHR (),  )
    ' fstring = replace (fstring, ", CHR)
 & nbsp;  fstring = Replace (fstring, "<br/>", CHR)
    htmldecode = fstring
End If
End Function

function Ubbcode (strcontent)
    if strallowhtml <> 1 then
         strcontent = HTMLEncode (strcontent)
    Else
  Strcontent = Htmlcode (strcontent)
    End If
    Dim re
    Set Re=new RegExp
    re. IgnoreCase =true
    re. Global=true

    re. Pattern= "\[img\] (. [ ^\[]*) \[\/img\] "
    strcontent=re. Replace (strcontent, "</img>")
    re. Pattern= "\[img=* ([0-9]*), * ([0-9]*) \] (. [ ^\[]*) \[\/img\] "
    strcontent=re. Replace (strcontent, "<a href=" "$") title= click to see full map target=_blank></img></a>"

        ' text mix
     Re. Pattern= "\[pic\] (. [ ^\[]*) \[\/pic\] "
    strcontent=re. Replace (strcontent, "</img>")
    re. Pattern= "\[pic=* ([0-9]*), * ([0-9]*) \] (. [ ^\[]*) \[\/pic\] "
    strcontent=re. Replace (strcontent, "<a href=" "$") title= click to see full map target=_blank></img></a> "



Re. Pattern= "\[flash=* ([0-9]*), * ([0-9]*) \] (. [ ^\[]*) \[\/flash\] "
Strcontent= Re. Replace (strcontent, "<embed src=" "$" "width=" "$" "height=" "$" "></EMBED>")
Re. Pattern= "\[flash\] (. [ ^\[]*) \[\/flash\] "
Strcontent= Re. Replace (strcontent, "<embed src=" "></EMBED>")

Re. Pattern= "(\[url\]) (http:\/\/.[ ^\[]*) (\[\/url\]) "
Strcontent= Re. Replace (strcontent, "<a href=" "$" "target=" "_blank" ">$2</A>")
Re. Pattern= "(\[url\]) (. [ ^\[]*) (\[\/url\]) "
Strcontent= Re. Replace (strcontent, "<a href=" "http://$2" "target=" "_blank" ">$2</A>")

Re. Pattern= "(\[email\]) (mailto:\/\/.[ ^\[]*) (\[\/email\]) "
Strcontent= Re. Replace (strcontent, "<a href=" "$" "target=" "_blank" ">$2</A>")
Re. Pattern= "(\[email\]) (. [ ^\[]*) (\[\/email\]) "
Strcontent= Re. Replace (strcontent, "<a href=" "mailto:$2" "target=" "_blank" ">$2</A>")

Re. Pattern= "(\[url= (http:\/\/.[ ^\[]*)\])(. [^\[]*) (\[\/url\]) "
Strcontent= Re. Replace (strcontent, "<a href=" "$" "target=" "_blank" ">$3</A>")
Re. Pattern= "(\[url= (. [ ^\[]*)\])(. [^\[]*) (\[\/url\]) "
Strcontent= Re. Replace (strcontent, "<a href=" "http://$2" "target=" "_blank" ">$3</A>")

Re. Pattern = "^" (http://[a-za-z0-9\./=\?%\ -&_~ ' @ ': +!] +)"
Strcontent = Re. Replace (strcontent, "<a Target=_blank href=$ 1>$1</a> ")
Re. Pattern = "(http://[a-za-z0-9\./=\?%\ -&_~ ' @ ': +!] +)$"
Strcontent = Re. Replace (strcontent, "<a Target=_blank href=$ 1>$1</a> ")
Re. pattern = "[^>=" "] (http://[a-za-z0-9\./=\?%\ -&_~ ' @ ': +!] +)"
Strcontent = Re. Replace (strcontent, "<a Target=_blank href=$ 1>$1</a> ")
Re. Pattern = "^" (ftp://[a-za-z0-9\./=\?%\ -&_~ ' @ ': +!] +)"
Strcontent = Re. Replace (strcontent, "<a Target=_blank href=$ 1>$1</a> ")
Re. Pattern = "(ftp://[a-za-z0-9\./=\?%\ -&_~ ' @ ': +!] +)$"
Strcontent = Re. Replace (strcontent, "<a Target=_blank href=$ 1>$1</a> ")
Re. pattern = "[^>=" "] (ftp://[a-za-z0-9\.\/=\?%\ -&_~ ' @ ': +!] +)"
Strcontent = Re. Replace (strcontent, "<a Target=_blank href=$ 1>$1</a> ")
Re. Pattern = "^" (rtsp://[a-za-z0-9\./=\?%\ -&_~ ' @ ': +!] +)"
Strcontent = Re. Replace (strcontent, "<a Target=_blank href=$ 1>$1</a> ")
Re. Pattern = "(rtsp://[a-za-z0-9\./=\?%\ -&_~ ' @ ': +!] +)$"
Strcontent = Re. Replace (strcontent, "<a Target=_blank href=$ 1>$1</a> ")
Re. pattern = "[^>=" "] (rtsp://[a-za-z0-9\.\/=\?%\ -&_~ ' @ ': +!] +)"
Strcontent = Re. Replace (strcontent, "<a Target=_blank href=$ 1>$1</a> ")
Re. Pattern = "^" (mms://[a-za-z0-9\./=\?%\ -&_~ ' @ ': +!] +)"
Strcontent = Re. Replace (strcontent, "<a Target=_blank href=$ 1>$1</a> ")
Re. Pattern = "(mms://[a-za-z0-9\./=\?%\ -&_~ ' @ ': +!] +)$"
Strcontent = Re. Replace (strcontent, "<a Target=_blank href=$ 1>$1</a> ")
Re. pattern = "[^>=" "] (mms://[a-za-z0-9\.\/=\?%\ -&_~ ' @ ': +!] +)"
Strcontent = Re. Replace (strcontent, "<a Target=_blank href=$ 1>$1</a> ")

Re. Pattern= "\[dir=* ([0-9]*), * ([0-9]*) \] (. [ ^\[]*) \[\/dir] "
Strcontent=re. Replace (strcontent, "<object classid=clsid:166b1bca-3f9c-11cf-8075-444553540000 codebase=http:// download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=7,0,2,0 width=$1 Height=$2><param name= SRC value=$3><embed src=$3 pluginspage=http://www.macromedia.com/shockwave/download/width=$1 height=$2> </embed></object> ")
Re. Pattern= "\[qt=* ([0-9]*), * ([0-9]*) \] (. [ ^\[]*) \[\/QT] "
Strcontent=re. Replace (strcontent, "<embed src=$3 width=$1 height=$2 autoplay=true loop=false controller=true playeveryframe=false Cache=false scale=tofit bgcolor= #000000 kioskmode=false targetcache=false pluginspage=http://www.apple.com/ Quicktime/> ")
Re. Pattern= "\[mp=* ([0-9]*), * ([0-9]*) \] (. [ ^\[]*) \[\/MP] "
Strcontent=re. Replace (strcontent, "<object align=middle classid=clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95 Class=OBJECT id= MediaPlayer width=$1 height=$2 ><param name=showstatusbar value=-1><param name=filename value=$3>< Embed Type=application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/ nsmp2inf.cab#version=5,1,52,701 flename=mp src=$3 width=$1 height=$2></embed></object> ")
Re. Pattern= "\[rm=* ([0-9]*), * ([0-9]*) \] (. [ ^\[]*) \[\/RM] "
Strcontent=re. Replace (strcontent, "<object CLASSID=CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA class=object Id=RAOCX width=$1 Height=$2><param name=src value=$3><param name=console value=clip1><param NAME=CONTROLS Imagewindow><param Name=autostart value=true></object><br><object Classid=CLSID: CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA height=32 Id=video2 Width=$1><param NAME=SRC VALUE=$3><PARAM AUTOSTART value=-1><param name=controls Value=controlpanel><param name=console VALUE=Clip1></ Object> ")


Re. Pattern= "(\[color= (. [ ^\[]*)\])(. [^\[]*) (\[\/color\]) "
Strcontent=re. Replace (strcontent, "<font color=" "$" ">$3</font>")
Re. Pattern= "(\[face= (. [ ^\[]*)\])(. [^\[]*) (\[\/face\]) "
Strcontent=re. Replace (strcontent, "<font face=" "$" ">$3</font>")
Re. Pattern= "(\[align= (. [ ^\[]*) \]) (. *) (\[\/align\]) "
Strcontent=re. Replace (strcontent, "<div align=" "$" ">$3</div>")

Re. Pattern= "(\[quote\]) (. *) (\[\/quote\])"
Strcontent=re. Replace (strcontent, "<table cellpadding=" "0" "cellspacing=" "0" "border=" "0" "width=" "94%" "bgcolor=" "#D7F0FF" " align= "center" "><tr><td><table width=" "100%" "cellpadding=" "5" "cellspacing=" "1" "border=" "0" " &GT;&LT;TR&GT;&LT;TD bgcolor= ' "&abgcolor&" ' >$2</table></table><br> "
Re. Pattern= "(\[fly\]) (. *) (\[\/fly\])"
Strcontent=re. Replace (strcontent, "<marquee width=" "90%" "behavior=" "Alternate" "Scrollamount=" "3" ">$2</marquee>")
Re. Pattern= "(\[move\]) (. *) (\[\/move\])"
Strcontent=re. Replace (strcontent, "<marquee scrollamount=" "3" ">$2</marquee>")
Re. Pattern= "\[glow=* ([0-9]*), * (#*[a-z0-9]*), * ([0-9]*) \] (. [ ^\[]*) \[\/glow] "
Strcontent=re. Replace (strcontent, "<table width=" "$" "style=" "Filter:glow (color=$2, strength=$3)" ">$4</table>")
Re. Pattern= "\[shadow=* ([0-9]*), * (#*[a-z0-9]*), * ([0-9]*) \] (. [ ^\[]*) \[\/shadow] "
Strcontent=re. Replace (strcontent, "<table width=$1 style=" "Filter:shadow (color=$2, strength=$3)" ">$4</table>")

Re. Pattern= "(\[i\]) (. [ ^\[]*) (\[\/i\]) "
Strcontent=re. Replace (strcontent, "<i>$2</i>")
Re. Pattern= "(\[u\]) (. [ ^\[]*) (\[\/u\]) "
Strcontent=re. Replace (strcontent, "<u>$2</u>")
Re. Pattern= "(\[b\]) (. [ ^\[]*) (\[\/b\]) "
Strcontent=re. Replace (strcontent, "<b>$2</b>")
Re. Pattern= "(\[fly\]) (. [ ^\[]*) (\[\/fly\]) "
Strcontent=re. Replace (strcontent, "<marquee>$2</marquee>")

Re. Pattern= "(\[size=1\]) (. [ ^\[]*) (\[\/size\]) "
Strcontent=re. Replace (strcontent, "<font size=" "1" ">$2</font>")
Re. Pattern= "(\[size=2\]) (. [ ^\[]*) (\[\/size\]) "
Strcontent=re. Replace (strcontent, "<font size=" "2" ">$2</font>")
Re. Pattern= "(\[size=3\]) (. [ ^\[]*) (\[\/size\]) "
Strcontent=re. Replace (strcontent, "<font size=" "3" ">$2</font>")
Re. Pattern= "(\[size=4\]) (. [ ^\[]*) (\[\/size\]) "
Strcontent=re. Replace (strcontent, "<font size=" "4" ">$2</font>")
Re. Pattern= "(\[center\]) (. [ ^\[]*) (\[\/center\]) "
Strcontent=re. Replace (strcontent, "<center>$2</center>")
' The following extensions
Re. Pattern= "(\[li\]) (. [ ^\[]*) (\[\/li\]) "
Strcontent=re. Replace (strcontent, "<li>$2</li>")
' Font background
Re. Pattern= "(\[fontbg= (. [ ^\[]*)\])(. [^\[]*) (\[\/fontbg\]) "
Strcontent=re. Replace (strcontent, "<span style=background-color:" "$" ">$3</span>")
' Delete line
Re. Pattern= "(\[strike\]) (. [ ^\[]*) (\[\/strike\]) "
Strcontent=re. Replace (strcontent, "<strike>$2</strike>")

Re. Pattern= "(\[html\]) (. [ ^\[]*) (\[\/html\]) "
Strcontent=re. Replace (strcontent, "<table width= ' 100% ' border= ' 0 ' cellspacing= ' 0 ' cellpadding= ' 6 ' bgcolor= '" &abgcolor& " ' ><td><b> below for program code:</b><br>$2</td></table> ')
Re. Pattern= "(\[code\]) (. [ ^\[]*) (\[\/code\]) "
Strcontent=re. Replace (strcontent, "<table width= ' 100% ' border= ' 0 ' cellspacing= ' 0 ' cellpadding= ' 6 ' bgcolor= '" &abgcolor& " ' ><td><b> below for program code:</b><br>$2</td></table> ')


Strcontent=chkbadwords (strcontent)

Set re=nothing
Ubbcode=strcontent
End Function
%>

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.