主题:  求助一个UBB

null

职务:普通成员
等级:1
金币:0.0
发贴:15
#12003/12/26 21:38:45
想达到的效果:插入html
我这样写:
     re.Pattern="(\[HTML\])(.[^\[]*)(\[\/HTML\])"
     strContent= re.Replace(strContent,HTMLDecode($2))
错了。
提示:
Microsoft VBScript 编译器错误 错误 '800a0408'

无效字符

/Ubb.asp,行102

strContent= re.Replace(strContent,HTMLDecode($2))
---------------------------------------------^

请问应该如何写?
或者有别的办法实现?



=ridincal=

职务:管理员
等级:7
金币:20.0
发贴:5886
#22003/12/26 22:06:27
(\[html\])(.[^\[]*)(\[\/html\])



null

职务:普通成员
等级:1
金币:0.0
发贴:15
#32003/12/26 22:10:48
不行~



=ridincal=

职务:管理员
等级:7
金币:20.0
发贴:5886
#42003/12/26 22:31:29
<script>
var regExp = new RegExp("(\\[html\\])(.[^\\[]*)(\\[\\/html\\])","ig");
var str = "asdwaeaw[html]0934758282[/html]asdfas";
regExp.exec(str);
str= str.replace(regExp,RegExp.$2);
alert(str);
</script>


[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]



null

职务:普通成员
等级:1
金币:0.0
发贴:15
#52003/12/26 22:42:48
谢谢,这个可以用……不过不是我要的。
我说明白一点吧:
就是比如这个论坛里,不允许html代码
但是我在一个只有自己能添加纪录的程序里面,我想采用ubb代码,但是由于ubb还不能实现html的所有功能(比如表格),所以想能实现这样的功能:
就是一般不能用html,但在[ html] [/ html]的中间的,能以显示出来。
要是说的还不够明白,把代码贴上来吧:
<%
function HTMLEncode(fString)
    if fString<>"" then
	    fString = replace(fString, ">", "&gt;")
	    fString = replace(fString, "<", "&lt;")    
	    fString = Replace(fString, CHR(32), " ")
	    fString = Replace(fString, " ", "&nbsp;")
    	    fString = Replace(fString, CHR(34), "&quot;")
    	    fString = Replace(fString, CHR(39), "&#39;")
    	    fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ")
    	    fString = Replace(fString, CHR(10), "<BR> ")
    end if
    HTMLEncode = fString
end function

function HTMLDecode(fString)

    fString = replace(fString, "&gt;", ">")
    fString = replace(fString, "&lt;", "<")

    fString = Replace(fString, "", CHR(13))
    fString = Replace(fString, "</P><P>", CHR(10) & CHR(10))
    fString = Replace(fString, "<BR>", CHR(10))
    HTMLDecode = fString
end function

function ubb(strContent)
       if strContent<>"" then	    	
	    strContent = HTMLEncode(strContent)
	    
	    dim re
	    Set re=new RegExp
	    re.IgnoreCase =true
	    re.Global=True
	    re.Pattern="(\[IMG\])(.[^\[]*)(\[\/IMG\])"
		strContent=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""></a>")
	    	    re.Pattern="(\[URL\])(.[^\[]*)(\[\/URL\])"
	    strContent= re.Replace(strContent,"<A HREF=""$2"" TARGET=_blank>$2</A>")
	    re.Pattern="(\[URL=(.[^\[]*)\])(.[^\[]*)(\[\/URL\])"
	    strContent= re.Replace(strContent,"<A HREF=""$2"" TARGET=_blank>$3</A>")

	    re.Pattern="(\[EMAIL\])(.[^\[]*)(\[\/EMAIL\])"
	    strContent= re.Replace(strContent,"<img align=absmiddle src=img/email.gif><A HREF=""mailto:$2"">$2</A>")
	    re.Pattern="(\[EMAIL=(.[^\[]*)\])(.[^\[]*)(\[\/EMAIL\])"
	    strContent= re.Replace(strContent,"<img align=absmiddle src=img/email1.gif><A HREF=""mailto:$2"" TARGET=_blank>$3</A>")

	    re.Pattern = "^(http://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)"
	    strContent = re.Replace(strContent,"<a target=_blank href=$1>$1</a>")
	    re.Pattern = "([^>=""])(http://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)"
	    strContent = re.Replace(strContent,"$1<a target=_blank href=$2>$2</a>")
	    re.Pattern = "^(ftp://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)"
	    strContent = re.Replace(strContent,"<a target=_blank href=$1>$1</a>")
	    re.Pattern = "([^>=""])(ftp://[A-Za-z0-9\.\/=\?%\-&_~`@':+!]+)"
	    strContent = re.Replace(strContent,"$1<a target=_blank href=$2>$2</a>")
	    re.Pattern = "^(rtsp://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)"
	    strContent = re.Replace(strContent,"<a target=_blank href=$1>$1</a>")
	    re.Pattern = "([^>=""])(rtsp://[A-Za-z0-9\.\/=\?%\-&_~`@':+!]+)"
	    strContent = re.Replace(strContent,"$1<a target=_blank href=$2>$2</a>")
	    re.Pattern = "^(mms://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)"
	    strContent = re.Replace(strContent,"<a target=_blank href=$1>$1</a>")
	    re.Pattern = "([^>=""])(mms://[A-Za-z0-9\.\/=\?%\-&_~`@':+!]+)"
	    strContent = re.Replace(strContent,"$1<a target=_blank href=$2>$2</a>")
	    re.Pattern="(\[fly\])(.*)(\[\/fly\])"
	    strContent=re.Replace(strContent,"<marquee width=90% behavior=alternate scrollamount=3>$2</marquee>")
	    re.Pattern="(\[move\])(.*)(\[\/move\])"
	    strContent=re.Replace(strContent,"<MARQUEE scrollamount=3>$2</marquee>")	
	    re.Pattern="\[GLOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/GLOW]"
	    strContent=re.Replace(strContent,"<table width=$1 style=""filter:glow(color=$2, strength=$3)"">$4</table>")
	    re.Pattern="\[SHADOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/SHADOW]"
	    strContent=re.Replace(strContent,"<table width=$1 style=""filter:shadow(color=$2, strength=$3)"">$4</table>")	    	    
	    re.Pattern="(\[em(.[^\]]*)\])"
	    strContent=re.Replace(strContent,"<img src=img/em$2.gif border=0 align=middle>")
	
	    re.Pattern="(\[face=(.[^\]]*)\])(.*)(\[\/face\])"
	    strContent=re.Replace(strContent,"<font face=$2>$3</font>")
	
	    re.Pattern="(\[i\])(.[^\[]*)(\[\/i\])"
	    strContent=re.Replace(strContent,"<i>$2</i>")
	    re.Pattern="(\[u\])(.[^\[]*)(\[\/u\])"
	    strContent=re.Replace(strContent,"<u>$2</u>")
	    re.Pattern="(\[b\])(.[^\[]*)(\[\/b\])"
	    strContent=re.Replace(strContent,"<b>$2</b>") 
	    re.Pattern="\[color=(.[^\]]*)\](.[^\[]*)\[\/color\]"
	    strContent=re.Replace(strContent,"<font color=$1>$2</font>")
	    re.Pattern="\[align=(.[^\]]*)\](.*)\[\/align\]"
	    strContent=re.Replace(strContent,"<div align=$1>$2</div>")
	    re.Pattern="(\[center\])(.[^\[]*)(\[\/center\])"
	    strContent=re.Replace(strContent,"<center>$2</center>")
	    re.Pattern="(\[HTML\])(.[^\[]*)(\[\/HTML\])"
	    strContent= re.Replace(strContent,HTMLDecode($2))
	    set re=Nothing
    end if
    ubb = strContent
end function
str="[color=red]test[/color][html]<hr>[/html]"
response.write ubb(str)
%>



null

职务:普通成员
等级:1
金币:0.0
发贴:15
#62003/12/26 22:55:06
我把那句改成
	    re.Pattern="(\[HTML\])(.[^\[]*)(\[\/HTML\])"
	    strContent= re.Replace(strContent,HTMLDecode("$2"))

这下倒没出错了,但是结果是:
test<hr>

那个< 和 >还是被htmlencode了……