栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > asp

asp.net ubb使用代码

asp 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

asp.net ubb使用代码

复制代码 代码如下:
////别人写的ubb代码

using System;
using System.Text;
using System.Text.Regularexpressions;
namespace Test.Com
{
///
/// 功能:UBB代码
/// 作者:Rexsp
/// 日期:2004-4-6
///

public class UBB
{
#region 构造函数
public UBB()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
#endregion
#region 公共静态方法
///
/// UBB代码处理函数
///

/// 输入字符串
/// 输出字符串
public static string UBBToHTML(string sDetail)
{
Regex r;
Match m;
#region 处理空格
sDetail = sDetail.Replace(" "," ");
#endregion
#region html标记符
sDetail = sDetail.Replace("<","<");
sDetail = sDetail.Replace(">",">");
#endregion
#region 处[b][/b]标记
r = new Regex(@"([b])([ St]*?)([/b])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),"" + m.Groups[2].ToString() + "");
}
#endregion
#region 处[i][/i]标记
r = new Regex(@"([i])([ St]*?)([/i])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),"" + m.Groups[2].ToString() + "");
}
#endregion
#region 处[u][/u]标记
r = new Regex(@"([U])([ St]*?)([/U])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),"" + m.Groups[2].ToString() + "");
}
#endregion
#region 处[p][/p]标记
//处[p][/p]标记
r = new Regex(@"((rn)*[p])(.*?)((rn)*[/p])",RegexOptions.IgnoreCase|RegexOptions.Singleline);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),"

" + m.Groups[3].ToString() + "

");
}
#endregion
#region 处[sup][/sup]标记
//处[sup][/sup]标记
r = new Regex(@"([sup])([ St]*?)([/sup])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),"" + m.Groups[2].ToString() + "");
}
#endregion
#region 处[sub][/sub]标记
//处[sub][/sub]标记
r = new Regex(@"([sub])([ St]*?)([/sub])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),"" + m.Groups[2].ToString() + "");
}
#endregion
#region 处[url][/url]标记
//处[url][/url]标记
r = new Regex(@"([url])([ St]*?)([/url])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"" +
m.Groups[2].ToString() + "");
}
#endregion
#region 处[url=xxx][/url]标记
//处[url=xxx][/url]标记
r = new Regex(@"([url=([ St]+)])([ St]*?)([/url])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"" +
m.Groups[3].ToString() + "");
}
#endregion
#region 处[email][/email]标记
//处[email][/email]标记
r = new Regex(@"([email])([ St]*?)([/email])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"" +
m.Groups[2].ToString() + "");
}
#endregion
#region 处[email=xxx][/email]标记
//处[email=xxx][/email]标记
r = new Regex(@"([email=([ St]+)])([ St]*?)([/email])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"" +
m.Groups[3].ToString() + "");
}
#endregion
#region 处[size=x][/size]标记
//处[size=x][/size]标记
r = new Regex(@"([size=([1-7])])([ St]*?)([/size])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"" +
m.Groups[3].ToString() + "
");
}
#endregion
#region 处[color=x][/color]标记
//处[color=x][/color]标记
r = new Regex(@"([color=([S]+)])([ St]*?)([/color])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"" +
m.Groups[3].ToString() + "
");
}
#endregion
#region 处[font=x][/font]标记
//处[font=x][/font]标记
r = new Regex(@"([font=([S]+)])([ St]*?)([/font])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"" +
m.Groups[3].ToString() + "
");
}
#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(),
""" target="_blank">"">");
}
#endregion
#region 处理[align=x][/align]
//处理[align=x][/align]
r = new Regex(@"([align=([S]+)])([ St]*?)([/align])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"

" +
m.Groups[3].ToString() + "

");
}
#endregion
#region 处[H=x][/H]标记
//处[H=x][/H]标记
r = new Regex(@"([H=([1-6])])([ St]*?)([/H])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
sDetail = sDetail.Replace(m.Groups[0].ToString(),
"" +
m.Groups[3].ToString() + "
");
}
#endregion
#region 处理[list=x][*][/list]
//处理[list=x][*][/list]
r = new Regex(@"([list(=(A|a|I|i| ))?]([ St]*)rn)(([*]([ St]*rn))*?)([/list])",RegexOptions.IgnoreCase);
for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
{
string strLI = m.Groups[5].ToString();
Regex rLI = new Regex(@"[*]([ St]*rn?)",RegexOptions.IgnoreCase);
Match mLI;
for (mLI = rLI.Match(strLI); mLI.Success; mLI = mLI.NextMatch())
{
strLI = strLI.Replace(mLI.Groups[0].ToString(),"
  • " + mLI.Groups[1]);
    }
    sDetail = sDetail.Replace(m.Groups[0].ToString(),
    "
      " + m.Groups[4].ToString() + "" +
      strLI + "
    ");
    }
    #endregion
    #region 处理换行
    //处理换行,在每个新行的前面添加两个全角空格
    r = new Regex(@"(rn(( )| )+)(?<正文>S+)",RegexOptions.IgnoreCase);
    for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
    {
    sDetail = sDetail.Replace(m.Groups[0].ToString(),"
      " + m.Groups["正文"].ToString());
    }
    //处理换行,在每个新行的前面添加两个全角空格
    sDetail = sDetail.Replace("rn","
    ");
    #endregion
    return sDetail;
    }
    #endregion
    }
    }


    asp.net(c#) ubb处理类
    https://www.jb51.net/article/15615.htm
  • 转载请注明:文章转载自 www.mshxw.com
    本文地址:https://www.mshxw.com/it/58963.html
    我们一直用心在做
    关于我们 文章归档 网站地图 联系我们

    版权所有 (c)2021-2022 MSHXW.COM

    ICP备案号:晋ICP备2021003244-6号