UBB代码对于经常上论坛的朋友来说是最熟悉不过了。
经典论坛的UBB转换我觉得是处理的非常好的,研究了一下它的转换结果[因为没有源码:)],做了下面的演示。转换结果基本上觉得象了。
主要是针对[code][html]这两个标签的处理,其他的UBB标签还是一般的处理方法。
下面是分别用javascript和vbscript实现的演示。自己做论坛的朋友,如果想实现类似经典论坛的运行代码框可以看看这种转换。
欢迎大家输入尽量多格式的UBB进行测试,多多指出错误。
javascript:
1<style>
2.CodeSamp {
3PADDING-RIGHT: 0.5em; MARGIN-TOP: 1em; PADDING-LEFT: 0.5em; FONT-SIZE: 8p; MARGIN-BOTTOM: 1em; PADDING-BOTTOM: 0.5em; MARGIN-LEFT: 0pt; PADDING-TOP: 0.5em; FONT-FAMILY: "Courier New"; BACKGROUND-COLOR: #eeeeee;width: 480px;overflow:hidden;border: 1px solid #888888;
4}
5textarea {
6border-width: 1; border-color: #000000;font-size: 12px;FONT-FAMILY: "Tahoma", "MS Shell Dlg";
7}
8</style>
1<textarea cols="65" name="phx" rows="12">
2[i][b][color=blue]blue[/color][/b][/i]
3
4[html][color=red]te
5st[/color][/html]
6
7[html][code]te
8st[/code][/html]
9
10[code][html]te
11st[/html][/code]</textarea>
1<button onclick='show.innerHTML=UBBCode(phx.value,"html")'>转换</button>
1<div id="show" style="border:1 solid skyblue;width=500;font-size: 12px;FONT-FAMILY:
2'Tahoma', 'MS Shell Dlg';
3"></div>
1<script>
2strIcons = "1" //允许笑脸转换
3strSmile="1" //同上
4ImgName="em"
5picurl="pic/"
6
7function UBBCode(content,html){
8st=new Date().getTime()
9content=content.replace(/\\[(\/)?phx_code\\]/ig,"{$1phx_code}");
10content=content.replace(/\\[(\/)?phx_html\\]/ig,"{$1phx_html}");
11content="[phx_code]"+content+"[/phx_code]";
12content=content.replace(/(\\[code\\]([\s\S]+?)\\[\/code\\])/ig,"[/phx_code]$1[phx_code]");
13content=content.replace(/\\[phx_code\\]([\s\S]*?)\\[\/phx_code\\]/ig,function($1,$2){if(html=="html"){return(HTMLCode($2));}else{return(trans($2));}});
14content=content.replace(/\\[code\\](\r\n)?([\s\S]+?)\\[\/code\\]/ig,function($1,$2,$3){return("<PRE class=CodeSamp>"+DvbbsHtmlAn($3)+"</PRE>")});
15content=content.replace(/\\{(\/)?phx_code\\}/ig,"[$1phx_code]");
16content=content.replace(/\\{(\/)?phx_html\\}/ig,"[$1phx_html]");
17alert('共耗时 '+eval(new Date().getTime()-st)+' ms');
18return(content);
19}
20
21function HTMLCode(content){
22content="[phx_html]"+content+"[/phx_html]";
23content=content.replace(/(\\[html\\]([\s\S]+?)\\[\/html\\])/ig,"[/phx_html]$1[phx_html]");
24content=content.replace(/\\[phx_html\\]([\s\S]*?)\\[\/phx_html\\]/ig,function($1,$2){return(trans($2))});
25content=content.replace(/\\[html\\]([\s\S]+?)\\[\/html\\]/ig,function($1,$2){return("<span><TEXTAREA cols=95 rows=12>"+hencode($2)+"</TEXTAREA><br><INPUT onclick=runCode() type=button value=运行代码>[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]</span>")});
26return(content);
27}
28
29function hencode(fString){ //简单模拟server.htmlencode ASP中不用这个
30fString = fString.replace(/&/ig,"&")
31fString = fString.replace(/>/ig,">") //>
32fString = fString.replace(/</ig,"<") //<
33return fString;
34}
35
36function DvbbsHtmlAn(fString){
37
38if(fString=="")return("");
39
40fString=hencode(fString)
41
42fString = fString.replace(/\t/ig," ") //Tab
43fString = fString.replace(/"/ig,""") //"
44fString = fString.replace(/'/ig,"'") //'
45fString = fString.replace(/\r/ig,"") //回车是一个13+10
46fString = fString.replace(/\n\n/ig,"<P>") //
47fString = fString.replace(/\n/ig,"<BR>") //换行
48fString = fString.replace(/\x20/ig," ") //空格
49
50
51return(fString);
52}
53
54function trans(strContent){
55var re;
56strContent=DvbbsHtmlAn(strContent);
57
58re=/\\[IMG\\](.+?)\\[\/IMG\\]/ig;
59strContent=strContent.replace(re,"<a href=$1 target=_blank><IMG SRC=$1 border=0 alt=按此在新窗口浏览图片 onload=\"javascript:if(this.width>screen.width-333)this.width=screen.width-333\" galleryImg=no></a>");
60re=/\\[DIR=*([0-9]*),*([0-9]*)\\](.*?)\\[\/DIR]/ig
61strContent=strContent.replace(re,"<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>")
62re=/\\[QT=*([0-9]*),*([0-9]*)\\](.*?)\\[\/QT]/ig
63strContent=strContent.replace(re,"<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/>")
64re=/\\[MP=*([0-9]*),*([0-9]*)\\](.*?)\\[\/MP]/ig
65strContent=strContent.replace(re,"<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>")
66re=/\\[RM=*([0-9]*),*([0-9]*)\\](.*?)\\[\/RM]/ig
67strContent=strContent.replace(re,"<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 VALUE=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 NAME=AUTOSTART VALUE=-1><PARAM NAME=CONTROLS VALUE=controlpanel><PARAM NAME=CONSOLE VALUE=Clip1></OBJECT>")
68
69
70re=/(\\[FLASH\\])(.*?)(\\[\/FLASH\\])/ig
71strContent= strContent.replace(re,"<OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,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/go/getflashplayer' type='application/x-shockwave-flash' width=500 height=400>$2</embed></OBJECT>")
72re=/(\\[FLASH=*([0-9]*),*([0-9]*)\\])(.*?)(\\[\/FLASH\\])/ig
73strContent= strContent.replace(re,"<a href=$4 TARGET=_blank><IMG SRC=pic/swf.gif border=0 alt=点击开新窗口欣赏该FLASH动画!> [全屏欣赏]</a><br><br><OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 width=$2 height=$3><PARAM NAME=movie VALUE=$4><PARAM NAME=quality VALUE=high><param name=menu value=false><embed src=$4 quality=high menu=false pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width=$2 height=$3>$4</embed></OBJECT>")
74
75re=/(\\[UPLOAD=gif\\])(.*?)(\\[\/UPLOAD\\])/ig
76strContent= strContent.replace(re,"<br><IMG SRC="+picurl+"gif.gif border=0>此主题相关图片如下:<br><A HREF=$2 TARGET=_blank><IMG SRC=$2 border=0 alt=按此在新窗口浏览图片 onload=\"javascript:if(this.width>screen.width-333)this.width=screen.width-333\"></A>")
77re=/(\\[UPLOAD=jpg\\])(.*?)(\\[\/UPLOAD\\])/ig
78strContent= strContent.replace(re,"<br><IMG SRC="+picurl+"jpg.gif border=0>此主题相关图片如下:<br><A HREF=$2 TARGET=_blank><IMG SRC=$2 border=0 alt=按此在新窗口浏览图片 onload=\"javascript:if(this.width>screen.width-333)this.width=screen.width-333\"></A>")
79re=/(\\[UPLOAD=bmp\\])(.*?)(\\[\/UPLOAD\\])/ig
80strContent= strContent.replace(re,"<br><IMG SRC="+picurl+"bmp.gif border=0>此主题相关图片如下:<br><A HREF=$2 TARGET=_blank><IMG SRC=$2 border=0 alt=按此在新窗口浏览图片 onload=\"javascript:if(this.width>screen.width-333)this.width=screen.width-333\"></A>")
81
82re=/(\\[UPLOAD=(.[^\\[]*)\\])(.*?)(\\[\/UPLOAD\\])/ig
83strContent= strContent.replace(re,"<br><IMG SRC="+picurl+"$2.gif border=0> <a href=$3>点击浏览该文件</a>")
84
85re=/(\\[URL\\])(.*?)(\\[\/URL\\])/ig
86strContent= strContent.replace(re,"<A HREF=$2 TARGET=_blank>$2</A>")
87re=/(\\[URL=(.[^\\[]*)\\])(.*?)(\\[\/URL\\])/ig
88strContent= strContent.replace(re,"<A HREF=$2 TARGET=_blank>$3</A>")
89
90re=/(\\[EMAIL\\])(.*?)(\\[\/EMAIL\\])/ig
91strContent= strContent.replace(re,"<img align=absmiddle src=pic/email1.gif><A HREF=\" mailto:$2\">$2</A >")
92re=/(\\[EMAIL=(.[^\\[]*)\\])(.*?)(\\[\/EMAIL\\])/ig
93strContent= strContent.replace(re,"<img align=absmiddle src=pic/email1.gif><A HREF=\" mailto:$2\ " TARGET=_blank>$3</A>")
94
95re =/^(http:\/\/[A-Za-z0-9\\.\/=\?%\\-&_~`@':+!]+)/ig
96strContent = strContent.replace(re,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
97re =/(http:\/\/[A-Za-z0-9\\.\/=\?%\\-&_~`@':+!]+)$/ig
98strContent = strContent.replace(re,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
99re =/[^>=""](http:\/\/[A-Za-z0-9\\.\/=\?%\\-&_~`@':+!]+)/ig
100strContent = strContent.replace(re,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
101re =/^(ftp:\/\/[A-Za-z0-9\\.\/=\?%\\-&_~`@':+!]+)/ig
102strContent = strContent.replace(re,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
103re =/(ftp:\/\/[A-Za-z0-9\\.\/=\?%\\-&_~`@':+!]+)$/ig
104strContent = strContent.replace(re,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
105re =/[^>=""](ftp:\/\/[A-Za-z0-9\\.\/=\?%\\-&_~`@':+!]+)/ig
106strContent = strContent.replace(re,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
107re =/^(rtsp:\/\/[A-Za-z0-9\\.\/=\?%\\-&_~`@':+!]+)/ig
108strContent = strContent.replace(re,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
109re =/(rtsp:\/\/[A-Za-z0-9\\.\/=\?%\\-&_~`@':+!]+)$/ig
110strContent = strContent.replace(re,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
111re =/[^>=""](rtsp:\/\/[A-Za-z0-9\\.\/=\?%\\-&_~`@':+!]+)/ig
112strContent = strContent.replace(re,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
113re =/^(mms:\/\/[A-Za-z0-9\\.\/=\?%\\-&_~`@':+!]+)/ig
114strContent = strContent.replace(re,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
115re =/(mms:\/\/[A-Za-z0-9\\.\/=\?%\\-&_~`@':+!]+)$/ig
116strContent = strContent.replace(re,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
117re =/[^>=""](mms:\/\/[A-Za-z0-9\\.\/=\?%\\-&_~`@':+!]+)/ig
118strContent = strContent.replace(re,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
119
120if(strIcons == "1"){ //笑脸转换
121re=/(\\[em(.*?)\\])/ig
122strContent=strContent.replace(re,"<img src="+picurl+ImgName+"$2.gif border=0 align=middle>")
123}
124
125if(strSmile == "1"){ //笑脸转换
126re=/(\\[s(\d{1,2})\\])/ig
127strContent=strContent.replace(re,"<img src=smile/face$2.gif border=0 align=middle>")
128}
129
130re=/(\\[color=(.[^\\[]*)\\])(.*?)(\\[\/color\\])/ig
131strContent=strContent.replace(re,"<font color=$2>$3</font>")
132re=/(\\[face=(.[^\\[]*)\\])(.*?)(\\[\/face\\])/ig
133strContent=strContent.replace(re,"<font face=$2>$3</font>")
134re=/(\\[align=(.[^\\[]*)\\])(.*?)(\\[\/align\\])/ig
135strContent=strContent.replace(re,"<div align=$2>$3</div>")
136//循环转换quote
137re=/(\\[QUOTE\\])(.*?)(\\[\/QUOTE\\])/ig
138while(strContent.indexOf("[quote]")>0 && strContent.indexOf("[/quote] ")>0){
139strContent=strContent.replace(re,"<blockquote>引用:<hr><span>$2</span><hr></blockquote>")
140}
141re=/(\\[fly\\])(.*?)(\\[\/fly\\])/ig
142strContent=strContent.replace(re,"<marquee width=90% behavior=alternate scrollamount=3>$2</marquee>")
143re=/(\\[move\\])(.*?)(\\[\/move\\])/ig
144strContent=strContent.replace(re,"<MARQUEE scrollamount=3>$2</marquee>")
145re=/\\[GLOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\\](.*?)\\[\/GLOW]/ig
146strContent=strContent.replace(re,"<table width=$1 style=\"filter:glow(color=$2, strength=$3)\">$4</table>")
147re=/\\[SHADOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\\](.*?)\\[\/SHADOW]/ig
148strContent=strContent.replace(re,"<table width=$1 style=\"filter:shadow(color=$2, strength=$3)\">$4</table>")
149
150re=/(\\[i\\])(.*?)(\\[\/i\\])/ig
151strContent=strContent.replace(re,"<i>$2</i>")
152re=/(\\[u\\])(.*?)(\\[\/u\\])/ig
153strContent=strContent.replace(re,"<u>$2</u>")
154re=/(\\[b\\])(.*?)(\\[\/b\\])/ig
155strContent=strContent.replace(re,"<b>$2</b>")
156
157re=/(\\[size=1\\])(.*?)(\\[\/size\\])/ig
158strContent=strContent.replace(re,"<font size=1>$2</font>")
159re=/(\\[size=2\\])(.*?)(\\[\/size\\])/ig
160strContent=strContent.replace(re,"<font size=2>$2</font>")
161re=/(\\[size=3\\])(.*?)(\\[\/size\\])/ig
162strContent=strContent.replace(re,"<font size=5>$2</font>")
163re=/(\\[size=4\\])(.*?)(\\[\/size\\])/ig
164strContent=strContent.replace(re,"<font size=6>$2</font>")
165
166re=/\\[size=([+|-]?[0-7])\\](.*?)(\\[\/size\\])/ig
167strContent=strContent.replace(re,"<font size=$1>$2</font>")
168
169re=/(\\[list\\])(.+?)(\\[\/list\\])/ig;
170strContent=strContent.replace(re,"<UL TYPE=SQUARE>$2<\/UL>");
171re=/(\\[list=)(A|1)(\\])(.+?)(\\[\/list\\])/ig;
172strContent=strContent.replace(re,"<OL TYPE=$2>$4<\/OL>");
173re=/(\\[\\*\\])/ig;
174strContent=strContent.replace(re,"<LI>");
175
176re=/(\\[center\\])(.*?)(\\[\/center\\])/ig
177strContent=strContent.replace(re,"<center>$2</center>")
178
179re=/(\\[table=(#*[a-z0-9]*),(#*[a-z0-9]*),(#*[a-z0-9]*)\\])(.*?)(\\[\/table\\])/ig
180strContent=strContent.replace(re,"<table border=0 cellpadding=5 cellspacing=1 bgcolor=$2><tr><td bgcolor=$3><font color=$4>$5</font></td></tr></table>")
181
182return(strContent);
183}
184</script>
VBScript:
1<style>
2.CodeSamp {
3PADDING-RIGHT: 0.5em; MARGIN-TOP: 1em; PADDING-LEFT: 0.5em; FONT-SIZE: 8p; MARGIN-BOTTOM: 1em; PADDING-BOTTOM: 0.5em; MARGIN-LEFT: 0pt; PADDING-TOP: 0.5em; FONT-FAMILY: "Courier New"; BACKGROUND-COLOR: #eeeeee;width: 480px;overflow:hidden;border: 1px solid #888888;
4}
5textarea {
6border-width: 1; border-color: #000000;font-size: 12px;FONT-FAMILY: "Tahoma", "MS Shell Dlg";
7}
8</style>
1<textarea cols="65" name="phx" rows="12">
2[i][b][color=blue]blue[/color][/b][/i]
3
4[html][color=red]te
5st[/color][/html]
6
7[html][code]te
8st[/code][/html]
9
10[code][html]te
11st[/html][/code]</textarea>
1<button onclick="show.innerHTML=UBBCode(phx.value)">转换</button>
1<div id="show" style="border:1 solid skyblue;width=500;font-size: 12px;FONT-FAMILY:
2'Tahoma', 'MS Shell Dlg';
3"></div>
1<script language="vbs">
2strIcons = "1" '允许笑脸转换
3strSmile="1" '同上
4ImgName="em"
5picurl="pic/"
6
7function UBBCode(content)
8'on error resume next
9st=timer
10set re=new regexp
11re.global=true
12
13re.pattern="\\[code\\](\r\n)?([\s\S]+?)\\[\/code\\]"
14Set Matches = re.Execute(content) ' Execute search.
15dim code()
16n=0
17if re.test(content) then codeb=true
18if codeb then
19For Each Match in Matches ' Iterate Matches collection.
20redim Preserve code(n)
21code(n) =Match.Value
22n=n+1
23Next
24for i=0 to ubound(code)
25if code(i)="" then exit for
26content=replace(content,code(i),"{code"&i&"}")
27next
28end if
29
30
31re.pattern="\\[html\\](\r\n)?([\s\S]+?)\\[\/html\\]"
32Set Matches = re.Execute(content) ' Execute search.
33dim html()
34n=0
35if re.test(content) then htmlb=true
36if htmlb then
37For Each Match in Matches ' Iterate Matches collection.
38redim Preserve html(n)
39html(n) =Match.Value
40n=n+1
41Next
42for i=0 to ubound(html)
43if html(i)="" then exit for
44content=replace(content,html(i),"{html"&i&"}")
45next
46end if
47
48content=gmt(content) 'ubb
49
50
51if codeb then
52for i=0 to ubound(code)
53if code(i)="" then exit for
54tcode=hencode(code(i))
55content=replace(content,"{code"&i&"}",tcode)
56next
57end if
58'-----
59re.pattern="\\[html\\](\r\n)?([\s\S]+?)\\[\/html\\]"
60Set Matches = re.Execute(content) ' Execute search.
61dim html2()
62n=0
63if re.test(content) then html2b=true
64if html2b then
65For Each Match in Matches ' Iterate Matches collection.
66redim Preserve html2(n)
67html2(n) =Match.Value
68n=n+1
69Next
70for i=0 to ubound(html2)
71if html2(i)="" then exit for
72content=replace(content,html2(i),"{html2"&i&"}")
73next
74end if
75
76
77if htmlb then
78for i=0 to ubound(html)
79if html(i)="" then exit for
80thtml=hencode(html(i))
81content=replace(content,"{html"&i&"}",thtml)
82next
83end if
84
85re.Pattern="(\\[code\\])(\r\n)?([\s\S]+?)(\\[\/code\\])"
86content=re.Replace(content,"<PRE class=CodeSamp>$3</PRE>")
87
88re.Pattern="(\\[html\\])(\r\n)?([\s\S]+?)(\\[\/html\\])"
89content=re.Replace(content,"<span><TEXTAREA cols=95 rows=12>$3</TEXTAREA><br><INPUT onclick=runCode() type=button value=运行代码>[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]</span>")
90
91if html2b then
92for i=0 to ubound(html2)
93if html2(i)="" then exit for
94thtml2=html2(i)
95content=replace(content,"{html2"&i&"}",thtml2)
96next
97end if
98
99UBBCode=content
100msgbox "转换共耗时 "&formatnumber((timer-st)*1000,2)&" ms"
101end function
102
103function hencode(fString) '简单模拟server.htmlencode ASP中不用这个
104fString = replace(fString,"&","&")
105fString = replace(fString,">",">")
106fString = replace(fString,"<","<")
107hencode=fString
108end function
109
110function DvbbsHtmlAn(fString)
111
112if not isnull(fString) then
113
114fString=hencode(fString)
115fString = Replace(fString, CHR(9), " ") 'Tab
116fString = Replace(fString, CHR(34), """) '"
117fString = Replace(fString, CHR(39), "'") ''
118fString = Replace(fString, CHR(13), "") '回车是一个13+10
119fString = Replace(fString, CHR(10) & CHR(10), "<P>")' '
120fString = Replace(fString, CHR(10), "<BR>")
121fString = Replace(fString, CHR(32), " ") ' 空格
122
123DvbbsHtmlAn = fString
124end if
125end function
126
127function gmt(strContent)
128
129strContent=DvbbsHtmlAn(strContent)
130
131dim re
132Set re=new RegExp
133re.IgnoreCase =true
134re.Global=True
135
136re.Pattern="(\\[IMG\\])(.*?)(\\[\/IMG\\])"
137strContent=re.Replace(strContent,"<a href=$2 target=_blank><IMG SRC=""$2"" border=0 alt=按此在新窗口浏览图片 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333"" galleryImg=no></a>")
138
139if Not UserSign or (UserSign and UserImgCode=1) then
140re.Pattern="\\[DIR=*([0-9]*),*([0-9]*)\\](.*?)\\[\/DIR]"
141strContent=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>")
142re.Pattern="\\[QT=*([0-9]*),*([0-9]*)\\](.*?)\\[\/QT]"
143strContent=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/>")
144re.Pattern="\\[MP=*([0-9]*),*([0-9]*)\\](.*?)\\[\/MP]"
145strContent=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>")
146re.Pattern="\\[RM=*([0-9]*),*([0-9]*)\\](.*?)\\[\/RM]"
147strContent=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 VALUE=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 NAME=AUTOSTART VALUE=-1><PARAM NAME=CONTROLS VALUE=controlpanel><PARAM NAME=CONSOLE VALUE=Clip1></OBJECT>")
148end if
149
150re.Pattern="(\\[FLASH\\])(.*?)(\\[\/FLASH\\])"
151strContent= re.Replace(strContent,"<OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,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/go/getflashplayer' type='application/x-shockwave-flash' width=500 height=400>$2</embed></OBJECT>")
152re.Pattern="(\\[FLASH=*([0-9]*),*([0-9]*)\\])(.*?)(\\[\/FLASH\\])"
153strContent= re.Replace(strContent,"<a href=""$4"" TARGET=_blank><IMG SRC=pic/swf.gif border=0 alt=点击开新窗口欣赏该FLASH动画!> [全屏欣赏]</a><br><br><OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 width=$2 height=$3><PARAM NAME=movie VALUE=""$4""><PARAM NAME=quality VALUE=high><param name=menu value=false><embed src=""$4"" quality=high menu=false pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width=$2 height=$3>$4</embed></OBJECT>")
154
155re.Pattern="(\\[UPLOAD=gif\\])(.*?)(\\[\/UPLOAD\\])"
156strContent= re.Replace(strContent,"<br><IMG SRC="""&picurl&"gif.gif"" border=0>此主题相关图片如下:<br><A HREF=""$2"" TARGET=_blank><IMG SRC=""$2"" border=0 alt=按此在新窗口浏览图片 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333""></A>")
157re.Pattern="(\\[UPLOAD=jpg\\])(.*?)(\\[\/UPLOAD\\])"
158strContent= re.Replace(strContent,"<br><IMG SRC="""&picurl&"jpg.gif"" border=0>此主题相关图片如下:<br><A HREF=""$2"" TARGET=_blank><IMG SRC=""$2"" border=0 alt=按此在新窗口浏览图片 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333""></A>")
159re.Pattern="(\\[UPLOAD=bmp\\])(.*?)(\\[\/UPLOAD\\])"
160strContent= re.Replace(strContent,"<br><IMG SRC="""&picurl&"bmp.gif"" border=0>此主题相关图片如下:<br><A HREF=""$2"" TARGET=_blank><IMG SRC=""$2"" border=0 alt=按此在新窗口浏览图片 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333""></A>")
161
162re.Pattern="(\\[UPLOAD=(.[^\\[]*)\\])(.*?)(\\[\/UPLOAD\\])"
163strContent= re.Replace(strContent,"<br><IMG SRC="""&picurl&"$2.gif"" border=0> <a href=""$3"">点击浏览该文件</a>")
164
165re.Pattern="(\\[URL\\])(.*?)(\\[\/URL\\])"
166strContent= re.Replace(strContent,"<A HREF=""$2"" TARGET=_blank>$2</A>")
167re.Pattern="(\\[URL=(.[^\\[]*)\\])(.*?)(\\[\/URL\\])"
168strContent= re.Replace(strContent,"<A HREF=""$2"" TARGET=_blank>$3</A>")
169
170re.Pattern="(\\[EMAIL\\])(.*?)(\\[\/EMAIL\\])"
171strContent= re.Replace(strContent,"<img align=absmiddle src=pic/email1.gif><A HREF="" mailto:$2"">$2</A >")
172re.Pattern="(\\[EMAIL=(.[^\\[]*)\\])(.*?)(\\[\/EMAIL\\])"
173strContent= re.Replace(strContent,"<img align=absmiddle src=pic/email1.gif><A HREF="" mailto:$2 "" TARGET=_blank>$3</A>")
174
175re.Pattern = "^( http://[A-Za-z0-9\\./=\?%\\-&_~`@' :+!]+)"
176strContent = re.Replace(strContent,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
177re.Pattern = "( http://[A-Za-z0-9\\./=\?%\\-&_~`@':+!]+)$ "
178strContent = re.Replace(strContent,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
179re.Pattern = "(<BR>|<P>)( http://[A-Za-z0-9\\./=\?%\\-&_~`@':+!]+)(<BR>|<P >)"
180strContent = re.Replace(strContent,"$1<img align=absmiddle src=pic/url.gif><a target=_blank href=$2>$2</a>$3")
181re.Pattern = "^( ftp://[A-Za-z0-9\\./=\?%\\-&_~`@' :+!]+)"
182strContent = re.Replace(strContent,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
183re.Pattern = "( ftp://[A-Za-z0-9\\./=\?%\\-&_~`@':+!]+)$ "
184strContent = re.Replace(strContent,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
185re.Pattern = "[^>=""]( ftp://[A-Za-z0-9\\.\/=\?%\\-&_~`@' :+!]+)"
186strContent = re.Replace(strContent,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
187re.Pattern = "^(rtsp://[A-Za-z0-9\\./=\?%\\-&_~`@':+!]+)"
188strContent = re.Replace(strContent,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
189re.Pattern = "(rtsp://[A-Za-z0-9\\./=\?%\\-&_~`@':+!]+)$"
190strContent = re.Replace(strContent,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
191re.Pattern = "[^>=""](rtsp://[A-Za-z0-9\\.\/=\?%\\-&_~`@':+!]+)"
192strContent = re.Replace(strContent,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
193re.Pattern = "^(mms://[A-Za-z0-9\\./=\?%\\-&_~`@':+!]+)"
194strContent = re.Replace(strContent,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
195re.Pattern = "(mms://[A-Za-z0-9\\./=\?%\\-&_~`@':+!]+)$"
196strContent = re.Replace(strContent,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
197re.Pattern = "[^>=""](mms://[A-Za-z0-9\\.\/=\?%\\-&_~`@':+!]+)"
198strContent = re.Replace(strContent,"<img align=absmiddle src=pic/url.gif><a target=_blank href=$1>$1</a>")
199
200if strIcons = "1" then '笑脸转换
201re.Pattern="(\\["&ImgName&"(.*?)\\])"
202strContent=re.Replace(strContent,"<img src="&picurl&ImgName&"$2.gif border=0 align=middle>")
203end if
204
205if strSmile = "1" then '笑脸转换
206re.Pattern="(\\[s(\d{1,2})\\])"
207strContent=re.Replace(strContent,"<img src=smile/face$2.gif border=0 align=middle>")
208end if
209
210
211re.Pattern="(\\[color=(.[^\\[]*)\\])(.*?)(\\[\/color\\])"
212strContent=re.Replace(strContent,"<font color=$2 style=""font-size:"&FontSize&"pt;line-height:"&FontHeight&"pt"">$3</font>")
213re.Pattern="(\\[face=(.[^\\[]*)\\])(.*?)(\\[\/face\\])"
214strContent=re.Replace(strContent,"<font face=$2 style=""font-size:"&FontSize&"pt;line-height:"&FontHeight&"pt"">$3</font>")
215re.Pattern="(\\[align=(.[^\\[]*)\\])(.*?)(\\[\/align\\])"
216strContent=re.Replace(strContent,"<div align=$2>$3</div>")
217'循环转换quote
218re.Pattern="(\\[QUOTE\\])(.*?)(\\[\/QUOTE\\])"
219while (instr(strContent,"[quote]")>0 and instr(strContent,"[/quote]")>0)
220strContent=re.Replace(strContent,"<blockquote>引用:<hr><span>$2</span><hr></blockquote>")
221wend
222re.Pattern="(\\[fly\\])(.*?)(\\[\/fly\\])"
223strContent=re.Replace(strContent,"<marquee width=90% behavior=alternate scrollamount=3>$2</marquee>")
224re.Pattern="(\\[move\\])(.*?)(\\[\/move\\])"
225strContent=re.Replace(strContent,"<MARQUEE scrollamount=3>$2</marquee>")
226re.Pattern="\\[GLOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\\](.*?)\\[\/GLOW]"
227strContent=re.Replace(strContent,"<table width=$1 style=""filter:glow(color=$2, strength=$3)"">$4</table>")
228re.Pattern="\\[SHADOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\\](.*?)\\[\/SHADOW]"
229strContent=re.Replace(strContent,"<table width=$1 style=""filter:shadow(color=$2, strength=$3)"">$4</table>")
230
231re.Pattern="(\\[i\\])(.*?)(\\[\/i\\])"
232strContent=re.Replace(strContent,"<i>$2</i>")
233re.Pattern="(\\[u\\])(.*?)(\\[\/u\\])"
234strContent=re.Replace(strContent,"<u>$2</u>")
235re.Pattern="(\\[b\\])(.*?)(\\[\/b\\])"
236strContent=re.Replace(strContent,"<b>$2</b>")
237
238re.Pattern="(\\[size=1\\])(.*?)(\\[\/size\\])"
239strContent=re.Replace(strContent,"<font size=1 style=""line-height:"&FontHeight&"pt"">$2</font>")
240re.Pattern="(\\[size=2\\])(.*?)(\\[\/size\\])"
241strContent=re.Replace(strContent,"<font size=2 style=""line-height:"&FontHeight&"pt"">$2</font>")
242re.Pattern="(\\[size=3\\])(.*?)(\\[\/size\\])"
243strContent=re.Replace(strContent,"<font size=5 style=""line-height:"&FontHeight&"pt"">$2</font>")
244re.Pattern="(\\[size=4\\])(.*?)(\\[\/size\\])"
245strContent=re.Replace(strContent,"<font size=6 style=""line-height:"&FontHeight&"pt"">$2</font>")
246
247re.Pattern="\\[size=([+|-]?[0-7])\\](.*?)(\\[\/size\\])"
248strContent=re.Replace(strContent,"<font size=$1 style=""line-height:"&FontHeight&"pt"">$2</font>")
249
250re.Pattern="(\\[center\\])(.*?)(\\[\/center\\])"
251strContent=re.Replace(strContent,"<center>$2</center>")
252
253re.Pattern="(\\[table=(#*[a-z0-9]*),(#*[a-z0-9]*),(#*[a-z0-9]*)\\])(.*?)(\\[\/table\\])"
254strContent=re.Replace(strContent,"<table border=0 cellpadding=5 cellspacing=1 bgcolor=$2><tr><td bgcolor=$3><font color=$4>$5</font></td></tr></table>")
255
256'[HTML/] start
257're.Pattern="(\\[html\\])(.*?)(\\[\/html\\])"
258'strContent=re.Replace(strContent,"<span><TEXTAREA cols=95 rows=12>$2</TEXTAREA><br><INPUT onclick=runCode() type=button value=运行代码>[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]</span>")
259
260
261'[HTML/] end
262
263
264
265set re=Nothing
266gmt=strContent
267end function
268
269</script>