<%
'website:http://www.angelasp.com
' Angel工作室技术开发团队:QQ:815657032、QQ：709047174
' Copyright (C) Angel工作室 (http://www.angelasp.com).  All rights reserved
	'UBB解析器,将UBB代码解析成HTML代码
	
	function ubb(code) 
		
		dim re
		set re = new RegExp     '创建正则对象
		re.IgnoreCase = true    '不考虑大小写
		re.Global = true        '全部筛选
		
		'换行
		if instr(code,"[br]") > 0 then
			re.pattern = "(\[br\])"
			code = re.replace(code,"<br />")
		end if
		
		'加粗
		if instr(code,"[/b]") > 0 then
			re.pattern = "(\[b\])(.[^\[]*)(\[\/b\])"    '匹配模式
			code = re.replace(code,"<strong>$2</strong>")
		end if
		
		'字体
		if instr(code,"[/font]") > 0 then
		re.pattern="\[font=(.[^\[]*)\]"
	    code=re.replace(code,"<font face=""$1"">")
		end if
		
		'倾斜
		if instr(code,"[/i]") > 0 then
			re.pattern = "(\[i\])(.[^\[]*)(\[\/i\])"    '匹配模式
			code = re.replace(code,"<em>$2</em>")
		end if
		
		'删除
		if instr(code,"[/s]") > 0 then
			re.pattern = "(\[s\])(.[^\[]*)(\[\/s\])"    '匹配模式
			code = re.replace(code,"<del>$2</del>")
		end if
		
		'下划线
		if instr(code,"[/u]") > 0 then
			re.pattern = "(\[u\])(.[^\[]*)(\[\/u\])"    '匹配模式
			code = re.replace(code,"<u>$2</u>")
		end if
		
		
		
		'字体大小
		if instr(code,"[/size]") > 0 then
		re.pattern="\[size=([1-5])\]"
	code=re.replace(code,"<font size=""$1"">")
		end if
		
		'颜色
		if instr(code,"[/color]") > 0 then
		re.pattern="\[color=(.[^\[]*)\]"
	code=re.replace(code,"<font color=""$1"">")
		end if
		
		'图片
		if instr(code,"[img") > 0 then
			re.pattern = "(\[img code=(.[^\[]*)\])"
			code = re.replace(code,"<img src='$2' alt='贴图' />")
		end if
		
		'超链接
		if instr(code,"[/url]") > 0 then
			re.pattern = "(\[url code=(.[^\[]*)\])(.[^\[]*)(\[\/url\])"
			code = re.replace(code,"<a href='$2' target='_blank'>$3</a>")
		end if
	
		'文字对齐方式UBB
	re.pattern="\[align=(center|left|right)\]"
	code=re.replace(code,"<div align=""$1"">")
	
	   '表格UBB
	re.pattern="\[table=(.[^\[]*)\]"
	code=re.replace(code,"<table width=""$1"">")
		set re = nothing
		
		ubb = code
	end function
%>