分享
 
 
 

UBB代码~(整理)

王朝软件设计·作者佚名  2004-07-16
窄屏简体版  字體: |||超大  

在论坛中,我常常要使用到特殊的显示效果,而要得到这些效果,我们通常都是使用ubb 函数来处理,下面是我整理的ubb代码~,有待完善~

[CODE]

'----------------------------------------------------------'

'--------------------UBBCode Function----------------------'

'----------------------------------------------------------'

Function UBBCode(ByVal strValue)

'忽略错误

On Error Resume Next

'定义变量

Dim RegExp

Dim strNewValue

Set RegExp = New RegExp

RegExp.IgnoreCase = True

RegExp.Global = True

strValue = UCase(HTMLEncode(strValue))

If strValue <> "" Then

RegExp.Pattern = "(\[URL\])(.[^\[]*)(\[\/URL\])"

strNewValue = RegExp.Replace(strValue,"<A HREF='HTTP://$2' TARGET='_BLANK'>$2</A>")

RegExp.Pattern = "(\[URL\])(HTTP:\/\/.[^\[]*)(\[\/URL\])"

strNewValue = RegExp.Replace(strValue,"<A HREF='$2' TARGET='_BLANK'>$2</A>")

RegExp.Pattern = "(\[URL=(HTTP:\/\/.[^\[]*)\])(.[^\[]*)(\[\/URL\])"

strNewValue = RegExp.Replace(strValue,"<A HREF='$2' TARGET='_BLANK'>$3</A>")

RegExp.Pattern = "(\[URL=(.[^\[]*)\])(.[^\[]*)(\[\/URL\])"

strNewValue = RegExp.Replace(strValue,"<A HREF='HTTP://$2' TARGET='_BLANK'>$3</A>")

RegExp.Pattern = "(\[IMG\])(.[^\[]*)(\[\/IMG\])"

strNewValue = RegExp.Replace(strNewValue,"<IMG SRC='$2' BORDER='0'>")

RegExp.Pattern = "(\[IMG=(HTTP:\/\/.[^\[]*)\])(\[\/IMG\])"

strNewValue = RegExp.Replace(strNewValue,"<IMG SRC='$2' BORDER='0'>")

RegExp.Pattern = "(\[IMG=(.[^\[]*)\])(\[\/IMG\])"

strNewValue = RegExp.Replace(strNewValue,"<IMG SRC='HTTP://$2' BORDER='0'>")

RegExp.Pattern = "(\[SIZE=([0-9]*)\])(.[^\[]*)(\[\/SIZE\])"

strNewValue = RegExp.Replace(strNewValue,"<FONT SIZE='$2'>$3</FONT>")

RegExp.Pattern = "(\[B\])(.[^\[]*)(\[\/B\])"

strNewValue = RegExp.Replace(strNewValue,"<B>$2</B>")

RegExp.Pattern = "(\[COLOR=(.[^\[]*)\])(.[^\[]*)(\[\/RED\])"

strNewValue = RegExp.Replace(strNewValue,"<FONT COLOR='$2'>$3</FONT>")

RegExp.Pattern = "(\[RED\])(.[^\[]*)(\[\/RED\])"

strNewValue = RegExp.Replace(strNewValue,"<FONT COLOR='#FF0000'>$2</FONT>")

RegExp.Pattern = "(\[GREEN\])(.[^\[]*)(\[\/GREEN\])"

strNewValue = RegExp.Replace(strNewValue,"<FONT COLOR='#009900'>$2</FONT>")

RegExp.Pattern = "(\[BLUE\])(.[^\[]*)(\[\/BLUE\])"

strNewValue = RegExp.Replace(strNewValue,"<FONT COLOR='#000099'>$2</FONT>")

RegExp.Pattern = "(\[GRAY\])(.[^\[]*)(\[\/GRAY\])"

strNewValue = RegExp.Replace(strNewValue,"<FONT COLOR='#999999'>$2</FONT>")

RegExp.Pattern = "(\[S\])(.[^\[]*)(\[\/S\])"

strNewValue = RegExp.Replace(strNewValue,"<FONT STYLE='TEXT-DECORATION:LINE-THROUGH'>$2</FONT>")

RegExp.Pattern = "(\[I\])(.[^\[]*)(\[\/I\])"

strNewValue = RegExp.Replace(strNewValue,"<I>$2</I>")

RegExp.Pattern = "(\[U\])(.[^\[]*)(\[\/U\])"

strNewValue = RegExp.Replace(strNewValue,"<U>$2</U>")

RegExp.Pattern = "(\[ALIGN=(.[^\[]*)\])(.[^\[]*)(\[\/ALIGN\])"

strNewValue = RegExp.Replace(strNewValue,"<DIV ALIGN='$2'>$3</DIV>")

RegExp.Pattern = "(\[CENTER\])(.[^\[]*)(\[\/CENTER\])"

strNewValue = RegExp.Replace(strNewValue,"<CENTER>$2</CENTER>")

RegExp.Pattern = "(\[EMAIL\])(.[^\[]*)(\[\/EMAIL\])"

strNewValue = RegExp.Replace(strNewValue,"<A HREF='MAILTO:$2'>$2</A>")

RegExp.Pattern = "(\[EMAIL=(.[^\[]*)\])(.[^\[]*)(\[\/EMAIL\])"

strNewValue = RegExp.Replace(strNewValue,"<A HREF='MAILTO:$2'>$3</A>")

RegExp.Pattern = "(\[FLY\])(.[^\[]*)(\[\/FLY\])"

strNewValue = RegExp.Replace(strNewValue,"<MARQUEE SCROLLAMOUT='3' BEHAVIOR='ALTERNATE' WIDTH='98%'>$2</MARQUEE>")

RegExp.Pattern = "(\[MOVE\])(.[^\[]*)(\[\/MOVE\])"

strNewValue = RegExp.Replace(strNewValue,"<MARQUEE SCROLLAMOUT='3'>$2</MARQUEE>")

RegExp.Pattern = "(\[MP=([0-9]*),([0-9]*)\])(.[^\[]*)(\[\/MP\])"

strNewValue = RegExp.Replace(strNewValue,"<OBJECT ALIGN='MIDDLE' CLASSID='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' CLASS='OBJECT' ID='MEDIAPLAYER' WIDTH='$2' HEIGHT='$3'><PARAM NAME='SHOWSTATUSBAR' VALUE='-1'><PARAM NAME='FILENAME' VALUE='$4'><EMBED TYPE='APPLICATION/X-OLEOBJECT' CODEBASE='HTTP://ACTIVEX.MICROSOFT.COM/ACTIVEX/CONTROLS/MPLAER/EN/NSMP2INF.CAB#VERSION=5,1,52,701' FILENAME=MP SRC='$4' WIDTH='$2' HEIGHT='$3'></EMBED></OBJECT>")

RegExp.Pattern = "(\[FLASH\])(.[^\[]*)(\[\/FLASH\])"

strNewValue = RegExp.Replace(strNewValue,"<OBJECT CODEBASE='HTTP://DOWNLOAD.MACROMEDIA.COM/PUB/SHOCKWAVE/CABS/FLASH/SWFLASH.CAB#VERSION=4,0,2,0' CLASSID='CLSID:D27CDB6E-AE6D-11CF-96B8-444553540000' WIDTH='500' HEIGHT='400'><PARAM NAME='MOVIE' VALUE='$2'><PARAM NAME='QUALITY' VALUE='HIGH'><EMBED SRC='$2' QUALITY='HIGH' PLUGINSPAGE='http://WWW..MACROMEDIA.COM/SHOCKWAVE/DOWNLOAD/INDEX.CGI?P1_PROD_VERSION=SHOCKWAVEFLASH' TYPE='APPLICATION/S-SHOCKWAVE-FLASH' WIDTH='500' HEIGHT='400'>$2</EMBED></OBJECT>")

RegExp.Pattern = "(\[QT=([0-9]*),([0-9]*)\])(.[^\[]*)(\[\/QT\])"

strNewValue = RegExp.Replace(strNewValue,"<EMBED SRC='$4' WIDTH='$2' HEIGHT='$3' AUTOPLAY='TRUE' LOOP='FALS'E CONTROLLER='TRUE' PLAYEVERYFRAME='FALSE' CACHE=FALSE SCALE='TOFIT' BGCOLOR='#000000' KIOSKMODE='FALSE' TARGETCACHE='FALSE' PLUGINSPAGE='HTTP://WWW.APPLE.COM/QUICKTIME/'>")

RegExp.Pattern = "(\[RM=([0-9]*),([0-9]*)\])(.[^\[]*)(\[\/RM\])"

strNewValue = RegExp.Replace(strNewValue,"<OBJECT CLASSID='CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA' CLASS='OBJECT' ID='RAOCX' WIDTH='$2' HEIGHT='$3'><PARAM NAME='SRC' VALUE='$4'><PARAM NAME='CONSOLE' VALUE='CLIP1'><PARAM NAME='CONTROLS' VALUE='IMAGEWINDOW'><PARAM NAME='AUTOSTART' VALUE='TRUE'></OBJECT><BR><OBJECT CLASSID='CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA' HEIGHT='32' ID='VIDEO2' WIDTH='$3'><PARAM NAME='SRC' VALUE='$4'><PARAM NAME='AUTOSTART' VALUE='-1'><PARAM NAME='CONTROLS' VALUE='CONTROLPANEL'><PARAM NAME='CONSOLE' VALUE='CLIP1'></OBJECT>")

End If

UBBCode = LCase(strNewValue)

'输出错误

If Err.Number>0 Then

Response.Write Err.Description

Response.End

End If

End Function

'----------------------------------------------------------'

'-------------------HTMLEncode Function--------------------'

'----------------------------------------------------------'

Function HTMLEncode(ByVal strValue)

'忽略错误

On Error Resume Next

'定义变量

Dim strNewValue

If strValue <> "" Then

strValue = Server.HTMLEncode(strValue)

strNewValue = Replace(strValue,"<","&lt;")

strNewValue = Replace(strNewValue,">","&gt;")

strNewValue = Replace(strNewValue,"'","&#39;")

strNewValue = Replace(strNewValue,"""","&quot;")

strNewValue = Replace(strNewValue,vbCrLf,"<br>")

strNewValue = Replace(strNewValue," ","&nbsp;")

End If

HTMLEncode = strNewValue

'输出错误

If Err.Number>0 Then

Response.Write Err.Description

Response.End

End If

End Function

[CODE]

使用的时候,在你的textarea中输入ubb代码,那么,在处理页面直接使用

content = UBBCode(Request.Form("content"))就可以咯~

关于ubb的书写,可以在网上搜索,我就不说咯!

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有