一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

asp ubb转换代码程序

时间:2010-04-14 编辑:简简单单 来源:一聚教程网

function UBBCode(strContent,ctype)
 on error resume next
 if ctype=1 then
 strContent = HTMLEncode(strContent)
 else
 strContent = strContent
 end if
 dim objRegExp
 Set objRegExp=new RegExp
 objRegExp.IgnoreCase =true
 objRegExp.Global=True
    if ctype=1 then
 objRegExp.Pattern="([URL])(.*?)([/URL])"
 strContent= objRegExp.Replace(strContent,"$2")
 objRegExp.Pattern="([URL=(.*?)])(.*?)([/URL])"
 strContent= objRegExp.Replace(strContent,"$3")
 objRegExp.Pattern="([EMAIL])(.*?)([/EMAIL])"
 strContent= objRegExp.Replace(strContent,"$2mailto:$2"">$2>")
 objRegExp.Pattern="([EMAIL=(.*?)])(.*?)([/EMAIL])"
 strContent= objRegExp.Replace(strContent,"
mailto:$2"" TARGET=_blank>$3")
 objRegExp.Pattern="([FLASH])(.*?)([/FLASH])"
 strContent= objRegExp.Replace(strContent,"flash/swflash.cab#version=4,0,2,0 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 >$2")
 objRegExp.Pattern="([IMG])(.*?)([/IMG])"
 strContent=objRegExp.Replace(strContent,"按此在新窗口浏览图片javascript教程:if(this.width>screen.width-660)this.">")
 '自动识别网址
    objRegExp.Pattern = "^((http|https教程|ftp|rtsp|mms):(//|\\)[A-Za-z0-9./=?%-&_~`@[]':+!]+)"
    strContent = objRegExp.Replace(strContent,"$1")
 objRegExp.Pattern = "((http|https|ftp|rtsp|mms):(//|\\)[A-Za-z0-9./=?%-&_~`@[]':+!]+)$"
 strContent = objRegExp.Replace(strContent,"$1")
 objRegExp.Pattern = "([^>=""])((http|https|ftp|rtsp|mms):(//|\\)[A-Za-z0-9./=?%-&_~`@[]':+!]+)"
 strContent = objRegExp.Replace(strContent,"$1$2")
    objRegExp.Pattern="([HTML])(.*?)([/HTML])"
 strContent=objRegExp.Replace(strContent,"

该篇文章附带的 HTML 代码片段如下:

[Ctrl+A 全部选择   提示:你可先修改部分代码,再按运行]
")
 objRegExp.Pattern="([color=(.*?)])(.*?)([/color])"
 strContent=objRegExp.Replace(strContent,"$3")
 objRegExp.Pattern="([face=(.*?)])(.*?)([/face])"
 strContent=objRegExp.Replace(strContent,"$3")
 objRegExp.Pattern="([align=(.*?)])(.*?)([/align])"
 strContent=objRegExp.Replace(strContent,"

$3
")
 objRegExp.Pattern="([QUOTE])(.*?)([/QUOTE])"
 strContent=objRegExp.Replace(strContent,"
quote:
$2
")
 objRegExp.Pattern="([fly])(.*?)([/fly])"
 strContent=objRegExp.Replace(strContent,"$2")
 objRegExp.Pattern="([move])(.*?)([/move])"
 strContent=objRegExp.Replace(strContent,"$2")
 objRegExp.Pattern="([glow=(.*?),(.*?),(.*?)])(.*?)([/glow])"
 strContent=objRegExp.Replace(strContent,"$5
")
 objRegExp.Pattern="([SHADOW=(.*?),(.*?),(.*?)])(.*?)([/SHADOW])"
 strContent=objRegExp.Replace(strContent,"$5
")
 objRegExp.Pattern="([i])(.*?)([/i])"
 strContent=objRegExp.Replace(strContent,"$2")
 objRegExp.Pattern="([u])(.*?)([/u])"
 strContent=objRegExp.Replace(strContent,"$2")
 objRegExp.Pattern="([b])(.*?)([/b])"
 strContent=objRegExp.Replace(strContent,"$2")
 objRegExp.Pattern="([fly])(.*?)([/fly])"
 strContent=objRegExp.Replace(strContent,"$2")
 objRegExp.Pattern="([size=1])(.*?)([/size])"
 strContent=objRegExp.Replace(strContent,"$2")
 objRegExp.Pattern="([size=2])(.*?)([/size])"
 strContent=objRegExp.Replace(strContent,"$2")
 objRegExp.Pattern="([size=3])(.*?)([/size])"
 strContent=objRegExp.Replace(strContent,"$2")
 objRegExp.Pattern="([size=4])(.*?)([/size])"
 strContent=objRegExp.Replace(strContent,"$2")
 strContent = doCode(strContent, "[list]", "[/list]", "
    ", "
")
 strContent = doCode(strContent, "[list=1]", "[/list]", "
    ", "
")
 strContent = doCode(strContent, "[list=a]", "[/list]", "
    ", "
")
 strContent = doCode(strContent, "[*]", "[/*]", "
  • ", "
  • ")
     strContent = doCode(strContent, "[code]", "[/code]", "
    ", "
    ")
     end if
        if ctype=1 or ctype=2 then
     objRegExp.Pattern="[UPLOAD=(gif|jpg|jpeg|bmp|png)](.[^[]*)(gif|jpg|jpeg|bmp|png)[/UPLOAD]"
     strContent= objRegExp.Replace(strContent,"
    按此在新窗口浏览图片screen.width-333)this.width=screen.width-333"">")
        objRegExp.Pattern="[UPLOAD=(.[^[]*)](.[^[]*)[/UPLOAD]"
        strContent= objRegExp.Replace(strContent,"
    点击浏览相关文件")
     end if
     set objRegExp=Nothing
     UBBCode=strContent
    end function

    热门栏目