配色: 字号:
$5
UBB 转换函数演示
2016-08-31 | 阅:  转:  |  分享 
  
UBB转换函数演示



[i][b][color=blue]blue[/color][/b][/i]

{html}[color=red]test[/color]{/html}

{html}[code]test[/code]{/html}

[code]{html}test{/html}[/code]
转换






vbscript:

复制代码代码如下:





[i][b][color=blue]blue[/color][/b][/i]

{html}[color=red]test[/color]{/html}

{html}[code]test[/code]{/html}

[code]{html}test{/html}[/code]
转换


strIcons="1"?''允许笑脸转换strSmile="1"??''同上ImgName="em"picurl="pic/"

functionUBBCode(content)''onerrorresumenextst=timersetre=newregexpre.global=true

re.pattern="\[code\](\r\n)?([\s\S]+?)\[\/code\]"SetMatches=re.Execute(content)牋''Executesearch.dimcode()n=0ifre.test(content)thencodeb=trueifcodebthen?ForEachMatchinMatches牋牋?''IterateMatchescollection.牋redimPreservecode(n)牋?code(n)=Match.Value牋?n=n+1?Nextfori=0toubound(code)ifcode(i)=""thenexitforcontent=replace(content,code(i),"{code"&i&"}")nextendif

re.pattern="\[html\](\r\n)?([\s\S]+?)\[\/html\]"SetMatches=re.Execute(content)牋''Executesearch.dimhtml()n=0ifre.test(content)thenhtmlb=trueifhtmlbthen?ForEachMatchinMatches牋牋?''IterateMatchescollection.牋redimPreservehtml(n)牋?html(n)=Match.Valuen=n+1?Nextfori=0toubound(html)ifhtml(i)=""thenexitforcontent=replace(content,html(i),"{html"&i&"}")nextendif

content=gmt(content)牋?''ubb

ifcodebthenfori=0toubound(code)ifcode(i)=""thenexitfortcode=hencode(code(i))content=replace(content,"{code"&i&"}",tcode)nextendif''-----re.pattern="\[html\](\r\n)?([\s\S]+?)\[\/html\]"SetMatches=re.Execute(content)牋''Executesearch.dimhtml2()n=0ifre.test(content)thenhtml2b=trueifhtml2bthen?ForEachMatchinMatches牋牋?''IterateMatchescollection.牋redimPreservehtml2(n)牋?html2(n)=Match.Valuen=n+1?Nextfori=0toubound(html2)ifhtml2(i)=""thenexitforcontent=replace(content,html2(i),"{html2"&i&"}")nextendif

ifhtmlbthenfori=0toubound(html)ifhtml(i)=""thenexitforthtml=hencode(html(i))content=replace(content,"{html"&i&"}",thtml)nextendif

re.Pattern="(\[code\])(\r\n)?([\s\S]+?)(\[\/code\])"content=re.Replace(content,"$3")

re.Pattern="(\[html\])(\r\n)?([\s\S]+?)(\[\/html\])"content=re.Replace(content,"$3
[Ctrl+A全部选择提示:你可先修改部分代码,再按运行]
")

ifhtml2bthenfori=0toubound(html2)ifhtml2(i)=""thenexitforthtml2=html2(i)content=replace(content,"{html2"&i&"}",thtml2)nextendif

UBBCode=contentmsgbox"转换共耗时"&formatnumber((timer-st)1000,2)&"ms"endfunction

?

functionhencode(fString)?''简单模拟server.htmlencode??ASP中不用这个?fString=replace(fString,"&","&")?fString=replace(fString,">",">")??fString=replace(fString,"<","<")?hencode=fStringendfunction

functionDvbbsHtmlAn(fString)

ifnotisnull(fString)thenfString=hencode(fString)?fString=Replace(fString,CHR(9),"???")?''Tab?fString=Replace(fString,CHR(34),""")???''"?fString=Replace(fString,CHR(39),"''")???''''?fString=Replace(fString,CHR(13),"")????''回车是一个13+10?fString=Replace(fString,CHR(10)&CHR(10),"

")''??''?fString=Replace(fString,CHR(10),"
")?fString=Replace(fString,CHR(32),"?")???''空格?DvbbsHtmlAn=fStringendifendfunction

functiongmt(strContent)

strContent=DvbbsHtmlAn(strContent)?dimre?Setre=newRegExp?re.IgnoreCase=true?re.Global=True

?re.Pattern="(\[IMG\])(.?)(\[\/IMG\])"?strContent=re.Replace(strContent,"screen.width-333)this.width=screen.width-333""galleryImg=no>")

爄fNotUserSignor(UserSignandUserImgCode=1)then爎e.Pattern="\[DIR=([0-9]),([0-9])\](.?)\[\/DIR]"爏trContent=re.Replace(strContent,"")爎e.Pattern="\[QT=([0-9]),([0-9])\](.?)\[\/QT]"爏trContent=re.Replace(strContent,"")爎e.Pattern="\[MP=([0-9]),([0-9])\](.?)\[\/MP]"爏trContent=re.Replace(strContent,"")爎e.Pattern="\[RM=([0-9]),([0-9])\](.?)\[\/RM]"爏trContent=re.Replace(strContent,"
")爀ndif

爎e.Pattern="(\[FLASH\])(.?)(\[\/FLASH\])"爏trContent=re.Replace(strContent,"$2")爎e.Pattern="(\[FLASH=([0-9]),([0-9])\])(.?)(\[\/FLASH\])"爏trContent=re.Replace(strContent,"[全屏欣赏]

$4")

爎e.Pattern="(\[UPLOAD=gif\])(.?)(\[\/UPLOAD\])"爏trContent=re.Replace(strContent,"
><此主题相关图片如下:
screen.width-333)this.width=screen.width-333"">")?re.Pattern="(\[UPLOAD=jpg\])(.?)(\[\/UPLOAD\])"?strContent=re.Replace(strContent,"
此主题相关图片如下:
screen.width-333)this.width=screen.width-333"">")?re.Pattern="(\[UPLOAD=bmp\])(.?)(\[\/UPLOAD\])"?strContent=re.Replace(strContent,"
此主题相关图片如下:
screen.width-333)this.width=screen.width-333"">")

?re.Pattern="(\[UPLOAD=(.[^\[])\])(.?)(\[\/UPLOAD\])"?strContent=re.Replace(strContent,"
点击浏览该文件")

?re.Pattern="(\[URL\])(.?)(\[\/URL\])"?strContent=re.Replace(strContent,"$2")?re.Pattern="(\[URL=(.[^\[])\])(.?)(\[\/URL\])"?strContent=re.Replace(strContent,"$3")

?re.Pattern="(\[EMAIL\])(.?)(\[\/EMAIL\])"?strContent=re.Replace(strContent,"$2")?re.Pattern="(\[EMAIL=(.[^\[])\])(.?)(\[\/EMAIL\])"?strContent=re.Replace(strContent,"$3")

?re.Pattern="^(http://[A-Za-z0-9\./=\?%\-&_~`@'':+!]+)"?strContent=re.Replace(strContent,"$1")?re.Pattern="(http://[A-Za-z0-9\./=\?%\-&_~`@'':+!]+)$"?strContent=re.Replace(strContent,"$1")?re.Pattern="(
|

)(http://[A-Za-z0-9\./=\?%\-&_~`@'':+!]+)(
|

)"?strContent=re.Replace(strContent,"$1$2$3")?re.Pattern="^(ftp://[A-Za-z0-9\./=\?%\-&_~`@'':+!]+)"?strContent=re.Replace(strContent,"$1")?re.Pattern="(ftp://[A-Za-z0-9\./=\?%\-&_~`@'':+!]+)$"?strContent=re.Replace(strContent,"$1")?re.Pattern="[^>=""](ftp://[A-Za-z0-9\.\/=\?%\-&_~`@'':+!]+)"?strContent=re.Replace(strContent,"$1")?re.Pattern="^(rtsp://[A-Za-z0-9\./=\?%\-&_~`@'':+!]+)"?strContent=re.Replace(strContent,"$1")?re.Pattern="(rtsp://[A-Za-z0-9\./=\?%\-&_~`@'':+!]+)$"?strContent=re.Replace(strContent,"$1")?re.Pattern="[^>=""](rtsp://[A-Za-z0-9\.\/=\?%\-&_~`@'':+!]+)"?strContent=re.Replace(strContent,"$1")?re.Pattern="^(mms://[A-Za-z0-9\./=\?%\-&_~`@'':+!]+)"?strContent=re.Replace(strContent,"$1")?re.Pattern="(mms://[A-Za-z0-9\./=\?%\-&_~`@'':+!]+)$"?strContent=re.Replace(strContent,"$1")?re.Pattern="[^>=""](mms://[A-Za-z0-9\.\/=\?%\-&_~`@'':+!]+)"?strContent=re.Replace(strContent,"$1")

?ifstrIcons="1"then??????????????????????''笑脸转换?re.Pattern="(\["&ImgName&"(.?)\])"?strContent=re.Replace(strContent,"")?endif

?ifstrSmile="1"then??????????????????????''笑脸转换?re.Pattern="(\[s(\d{1,2})\])"?strContent=re.Replace(strContent,"")?endif

?re.Pattern="(\[color=(.[^\[])\])(.?)(\[\/color\])"?strContent=re.Replace(strContent,"$3")?re.Pattern="(\[face=(.[^\[])\])(.?)(\[\/face\])"?strContent=re.Replace(strContent,"$3")?re.Pattern="(\[align=(.[^\[])\])(.?)(\[\/align\])"?strContent=re.Replace(strContent,"$3")''循环转换quote?re.Pattern="(\[QUOTE\])(.?)(\[\/QUOTE\])"?while(instr(strContent,"[quote]")>0andinstr(strContent,"[/quote]")>0)?strContent=re.Replace(strContent,"

引用:
$2
")?wend?re.Pattern="(\[fly\])(.?)(\[\/fly\])"?strContent=re.Replace(strContent,"$2")?re.Pattern="(\[move\])(.?)(\[\/move\])"?strContent=re.Replace(strContent,"$2")??re.Pattern="\[GLOW=([0-9]),(#[a-z0-9]),([0-9])\](.?)\[\/GLOW]"?strContent=re.Replace(strContent,"$4
")?re.Pattern="\[SHADOW=([0-9]),(#[a-z0-9]),([0-9])\](.?)\[\/SHADOW]"?strContent=re.Replace(strContent,"$4
")

?re.Pattern="(\[i\])(.?)(\[\/i\])"?strContent=re.Replace(strContent,"$2")?re.Pattern="(\[u\])(.?)(\[\/u\])"?strContent=re.Replace(strContent,"$2")?re.Pattern="(\[b\])(.?)(\[\/b\])"?strContent=re.Replace(strContent,"$2")

?re.Pattern="(\[size=1\])(.?)(\[\/size\])"?strContent=re.Replace(strContent,"$2")?re.Pattern="(\[size=2\])(.?)(\[\/size\])"?strContent=re.Replace(strContent,"$2")?re.Pattern="(\[size=3\])(.?)(\[\/size\])"?strContent=re.Replace(strContent,"$2")?re.Pattern="(\[size=4\])(.?)(\[\/size\])"?strContent=re.Replace(strContent,"$2")?re.Pattern="\[size=([+|-]?[0-7])\](.?)(\[\/size\])"?strContent=re.Replace(strContent,"$2")

?re.Pattern="(\[center\])(.?)(\[\/center\])"?strContent=re.Replace(strContent,"
$2
")

?re.Pattern="(\[table=(#[a-z0-9]),(#[a-z0-9]),(#[a-z0-9])\])(.?)(\[\/table\])"?strContent=re.Replace(strContent,"
")

''{HTML}start?''re.Pattern="(\[html\])(.?)(\[\/html\])"?''strContent=re.Replace(strContent,"$2
[Ctrl+A全部选择提示:你可先修改部分代码,再按运行]
")???????

''{/HTML}end???

?setre=Nothing?gmt=strContentendfunction





献花(0)
+1
(本文系爱就请温柔...首藏)
类似文章 更多
发表评论: