asp.net ubb使用代碼
更新時(shí)間:2009年12月22日 22:26:19 作者:
asp.net ubb使用代碼,以前腳本之家曾經(jīng)發(fā)過一篇稍有區(qū)別的代碼,大家一起參考下吧。
復(fù)制代碼 代碼如下:
////別人寫的ubb代碼
using System;
using System.Text;
using System.Text.RegularExpressions;
namespace Test.Com
{
/// <summary>
/// 功能:UBB代碼
/// 作者:Rexsp
/// 日期:2004-4-6
/// </summary>
public class UBB
{
#region 構(gòu)造函數(shù)
public UBB()
{
//
// TODO: 在此處添加構(gòu)造函數(shù)邏輯
//
}
#endregion
#region 公共靜態(tài)方法
/// <summary>
/// UBB代碼處理函數(shù)
/// </summary>
/// <param name="sDetail">輸入字符串</param>
/// <returns>輸出字符串</returns>
public static string UBBToHTML(string sDetail)
{
Regex r;
Match m;
#region 處理空格
sDetail = sDetail.Replace(" "," ");
#endregion
#region html標(biāo)記符
sDetail = sDetail.Replace("<","<");
sDetail = sDetail.Replace(">",">");
#endregion
#region 處[b][/b]標(biāo)記
r = new Regex(@"(\[b\])([ \S\t]*?)(\[\/b\])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),"<B>" + m.Groups[2].ToString() + "</B>");
}
#endregion
#region 處[i][/i]標(biāo)記
r = new Regex(@"(\[i\])([ \S\t]*?)(\[\/i\])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),"<I>" + m.Groups[2].ToString() + "</I>");
}
#endregion
#region 處[u][/u]標(biāo)記
r = new Regex(@"(\[U\])([ \S\t]*?)(\[\/U\])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),"<U>" + m.Groups[2].ToString() + "</U>");
}
#endregion
#region 處[p][/p]標(biāo)記
//處[p][/p]標(biāo)記
r = new Regex(@"((\r\n)*\[p\])(.*?)((\r\n)*\[\/p\])",RegexOptions.IgnoreCase|RegexOptions.Singleline);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),"<P class=\"pstyle\">" + m.Groups[3].ToString() + "</P>");
}
#endregion
#region 處[sup][/sup]標(biāo)記
//處[sup][/sup]標(biāo)記
r = new Regex(@"(\[sup\])([ \S\t]*?)(\[\/sup\])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),"<SUP>" + m.Groups[2].ToString() + "</SUP>");
}
#endregion
#region 處[sub][/sub]標(biāo)記
//處[sub][/sub]標(biāo)記
r = new Regex(@"(\[sub\])([ \S\t]*?)(\[\/sub\])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),"<SUB>" + m.Groups[2].ToString() + "</SUB>");
}
#endregion
#region 處[url][/url]標(biāo)記
//處[url][/url]標(biāo)記
r = new Regex(@"(\[url\])([ \S\t]*?)(\[\/url\])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"<A href=\"" + m.Groups[2].ToString() + "\" target=\"_blank\"><IMG border=0 src=\"images/url.gif\">" +
m.Groups[2].ToString() + "</A>");
}
#endregion
#region 處[url=xxx][/url]標(biāo)記
//處[url=xxx][/url]標(biāo)記
r = new Regex(@"(\[url=([ \S\t]+)\])([ \S\t]*?)(\[\/url\])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"<A href=\"" + m.Groups[2].ToString() + "\" target=\"_blank\"><IMG border=0 src=\"images/url.gif\">" +
m.Groups[3].ToString() + "</A>");
}
#endregion
#region 處[email][/email]標(biāo)記
//處[email][/email]標(biāo)記
r = new Regex(@"(\[email\])([ \S\t]*?)(\[\/email\])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"<A href=\"mailto:" + m.Groups[2].ToString() + "\" target=\"_blank\"><IMG border=0 src=\"images/email.gif\">" +
m.Groups[2].ToString() + "</A>");
}
#endregion
#region 處[email=xxx][/email]標(biāo)記
//處[email=xxx][/email]標(biāo)記
r = new Regex(@"(\[email=([ \S\t]+)\])([ \S\t]*?)(\[\/email\])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"<A href=\"mailto:" + m.Groups[2].ToString() + "\" target=\"_blank\"><IMG border=0 src=\"images/email.gif\">" +
m.Groups[3].ToString() + "</A>");
}
#endregion
#region 處[size=x][/size]標(biāo)記
//處[size=x][/size]標(biāo)記
r = new Regex(@"(\[size=([1-7])\])([ \S\t]*?)(\[\/size\])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"<FONT SIZE=" + m.Groups[2].ToString() + ">" +
m.Groups[3].ToString() + "</FONT>");
}
#endregion
#region 處[color=x][/color]標(biāo)記
//處[color=x][/color]標(biāo)記
r = new Regex(@"(\[color=([\S]+)\])([ \S\t]*?)(\[\/color\])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"<FONT COLOR=" + m.Groups[2].ToString() + ">" +
m.Groups[3].ToString() + "</FONT>");
}
#endregion
#region 處[font=x][/font]標(biāo)記
//處[font=x][/font]標(biāo)記
r = new Regex(@"(\[font=([\S]+)\])([ \S\t]*?)(\[\/font\])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"<FONT FACE=" + m.Groups[2].ToString() + ">" +
m.Groups[3].ToString() + "</FONT>");
}
#endregion
#region 處理圖片鏈接
//處理圖片鏈接
r = new Regex("\\[picture\\](\\d+?)\\[\\/picture\\]",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"<A href=\"ShowImage.aspx?Type=ALL&Action=forumImage&ImageID=" + m.Groups[1].ToString() +
"\" target=\"_blank\"><IMG border=0 Title=\"點(diǎn)擊打開新窗口查看\" src=\"ShowImage.aspx?Action=forumImage&ImageID=" + m.Groups[1].ToString() +
"\"></A>");
}
#endregion
#region 處理[align=x][/align]
//處理[align=x][/align]
r = new Regex(@"(\[align=([\S]+)\])([ \S\t]*?)(\[\/align\])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"<P align=" + m.Groups[2].ToString() + ">" +
m.Groups[3].ToString() + "</P>");
}
#endregion
#region 處[H=x][/H]標(biāo)記
//處[H=x][/H]標(biāo)記
r = new Regex(@"(\[H=([1-6])\])([ \S\t]*?)(\[\/H\])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"<H" + m.Groups[2].ToString() + ">" +
m.Groups[3].ToString() + "</H" + m.Groups[2].ToString() + ">");
}
#endregion
#region 處理[list=x][*][/list]
//處理[list=x][*][/list]
r = new Regex(@"(\[list(=(A|a|I|i| ))?\]([ \S\t]*)\r\n)((\[\*\]([ \S\t]*\r\n))*?)(\[\/list\])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
string strLI = m.Groups[5].ToString();
Regex rLI = new Regex(@"\[\*\]([ \S\t]*\r\n?)",RegexOptions.IgnoreCase);
Match mLI;
for (mLI = rLI.Match(strLI); mLI.Success; mLI = mLI.NextMatch())
{
strLI = strLI.Replace(mLI.Groups[0].ToString(),"<LI>" + mLI.Groups[1]);
}
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"<UL TYPE=\"" + m.Groups[3].ToString() + "\"><B>" + m.Groups[4].ToString() + "</B>" +
strLI + "</UL>");
}
#endregion
#region 處理換行
//處理換行,在每個(gè)新行的前面添加兩個(gè)全角空格
r = new Regex(@"(\r\n(( )| )+)(?<正文>\S+)",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),"<BR> " + m.Groups["正文"].ToString());
}
//處理換行,在每個(gè)新行的前面添加兩個(gè)全角空格
sDetail = sDetail.Replace("\r\n","<BR>");
#endregion
return sDetail;
}
#endregion
}
}
asp.net(c#) ubb處理類
http://www.dbjr.com.cn/article/15615.htm
相關(guān)文章
asp.net+js實(shí)現(xiàn)的ajax sugguest搜索提示效果
阿會(huì)楠根據(jù)網(wǎng)上一份原作者不詳?shù)拇a進(jìn)行了修改,以適合自己的項(xiàng)目并增加了多個(gè)功能。此次放出的代碼為基本實(shí)現(xiàn)代碼,也是最接近原來的代碼,略去其他功能。版權(quán)歸原作者所有。2009-04-04一步一步學(xué)asp.net Ajax登錄設(shè)計(jì)實(shí)現(xiàn)解析
做一個(gè)登錄,擁有自動(dòng)記住賬號(hào)和密碼的功能,要保證安全性,ajax,無刷新,良好的用戶體驗(yàn).(母板頁)2012-05-05asp.net listbox實(shí)現(xiàn)單選全選取消
這篇文章主要介紹了asp.net listbox單選全選取消的應(yīng)用,需要的朋友可以參考下2014-02-02ADO調(diào)用分頁查詢存儲(chǔ)過程的實(shí)例講解
下面小編就為大家分享一篇ADO調(diào)用分頁查詢存儲(chǔ)過程的實(shí)例講解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2017-12-12利用MS AJAX注冊(cè)Javascript命名空間并創(chuàng)建類
利用MS AJAX注冊(cè)Javascript命名空間并創(chuàng)建類...2007-10-10win10下ASP.NET Core部署環(huán)境搭建步驟
這篇文章主要以圖文結(jié)合的方式介紹了win10下ASP.NET Core部署環(huán)境搭建步驟,感興趣的小伙伴們可以參考一下2016-07-07