求一代UBB代码 反向的
就是说在编辑贴子的时候
格式从数据库出来的时候
也要以 [][] 这种格式显示
我现在只有进行数据库里的UBB
麻烦高手给一段反向的
如下:
Function UBB(str)
Dim regEx
Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Global = True
'code
'url
regEx.Pattern="(\[url\])(http:\/\/\S+)(\[\/url\])"
str=regEx.Replace(str,"<a href=""$2"" target=_blank>$2</a>")
regEx.Pattern="(\[url\])(\S+)(\[\/url\])"
str=regEx.Replace(str,"<a href=""http://$2"" target=_blank>http://$2</a>")
'img
regEx.Pattern="(\[img\])(http:\/\/\S+(\.gif|\.jpg))(\[\/img\])"
str=regEx.Replace(str,"<img src=$2 >")
regEx.Pattern="(\[img\])(\S+(\.gif|\.jpg))(\[\/img\])"
str=regEx.Replace(str,"<img src=""http://\S+?(\.gif|\.jpg)"">")
'mail
regEx.Pattern="(\[email\])(\w+@[0-9a-zA-Z_\.]+\.[a-zA-Z]{2,3})(\[\/email\])"
str=regEx.Replace(str,"<a href=""mailto:$2"">$2</a>")
'sup
regEx.Pattern="(\[sup\])(\S+)(\[\/sup\])"
str=regEx.Replace(str,"<sup>$2</sup>")
'sub
regEx.Pattern="(\[sub\])(\S+)(\[\/sub\])"
str=regEx.Replace(str,"<sub>$2</sub>")
'hr
regEx.Pattern="(\[hr\])"
str=regEx.Replace(str,"<hr width=""95%"">")
'b
regEx.Pattern="(\[b\])([\S\n\r ]+)(\[\/b\])"
str=regEx.Replace(str,"<b>$2</b>")
'center
regEx.Pattern="(\[center\])([\S\n\r ]+)(\[\/center\])"
str=regEx.Replace(str,"<center>$2</center>")
'left
regEx.Pattern="(\[left\])([\S\n\r ]+)(\[\/left\])"
str=regEx.Replace(str,"<div align=left>$2</div>")
'right
regEx.Pattern="(\[right\])([\S\n\r ]+)(\[\/right\])"
str=regEx.Replace(str,"<div align=right>$2</div>")
'red
regEx.Pattern="(\[red\])([\S\n\r ]+)(\[\/red\])"
str=regEx.Replace(str,"<font color=""red"">$2</font>")
'blue
regEx.Pattern="(\[blue\])([\S\n\r ]+)(\[\/blue\])"
str=regEx.Replace(str,"<font color=""blue"">$2</font>")
'green
regEx.Pattern="(\[green\])([\S\n\r ]+)(\[\/green\])"
str=regEx.Replace(str,"<font color=""green"">$2</font>")
'#
regEx.Pattern="(\[#([0-9a-fA-F]{6,6})\])([\S\n\r ]+)(\[\/#\])"
str=regEx.Replace(str,"<font color=""#$2"">$3</font>")
Set regEx=nothing
UBB=str
End Function