当前位置:编程学习 > asp >>

ubb代码转化html代码

public static string UbbDecode(string str)
{
str = HtmlEncode(str);
str = Regex.Replace(str, @"[url](?<url>.+?)[/url]", "<a href='${url}' target=_blank>${url}</a>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"[url=(?<url>.+?)](?<name>.+?)[/url]", "<a href='${url}' target=_blank>${name}</a>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"[email](?<email>.+?)[/email]", "<a href='mailt${email}' target=_blank>${email}</a>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"[email=(?<email>.+?)](?<name>.+?)[/email]", "<a href='mailt${email}' target=_blank>${name}</a>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"[flash](?<flash>.+?)[/flash]", "<div style='width:640;text-align:left'><a href='${flash}'>[u5168u5c4fu67e5u770b]</a></div><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=640 height=480><PARAM NAME=movie VALUE='${flash}'><PARAM NAME=quality VALUE=high><embed src='${flash}' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width=640 height=480></embed></OBJECT>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"[dir=(?<width>[0-9]+?),(?<height>[0-9]+?)](?<url>.+?)[/dir]", "<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=${width} height=${height}><param name=src value=${url}><embed src=${url} pluginspage=http://www.macromedia.com/shockwave/download/ width=${width} height=${height}></embed></object>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
补充:asp教程,脚本编码
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,