请问在ASP.NET页面中如何调用这个UBB类
各位大师能不能给个完整的示例
using System;
using System.Text;
using System.Text.RegularExpressions;
namespace Test.Com
{
/// <summary>
 /// 功能:UBB代码
 /// 作者:Rexsp
 /// 日期:2004-4-6
 /// </summary>
 public class UBB
 {
  #region 构造函数
  public UBB()
  {
   //
   // TODO: 在此处添加构造函数逻辑
   //
  }
  #endregion
  #region 公共静态方法
  /// <summary>
  /// UBB代码处理函数
  /// </summary>
  /// <param name="sDetail">输入字符串</param>
  /// <returns>输出字符串</returns>
  public static string UBBToHTML(string sDetail)
  {
   Regex r;
   Match m;
   #region 处理空格
   sDetail = sDetail.Replace(" ","&nbsp;");
   #endregion
   #region html标记符
   sDetail = sDetail.Replace("<","&lt;");
   sDetail = sDetail.Replace(">","&gt;");
   #endregion
   #region 处标记
   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 处标记
   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 处标记
   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]标记
   //处[p][/p]标记
   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]标记
   //处[sup][/sup]标记
   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]标记
   //处[sub][/sub]标记
   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 处标记
   //处标记
   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 处xxx标记

解决方案 »

  1.   

    //处xxx标记
       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]标记
       //处[email][/email]标记
       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]标记
       //处[email=xxx][/email]标记
       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]标记
       //处[size=x][/size]标记
       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 处标记
       //处标记
       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]标记
       //处[font=x][/font]标记
       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=\"点击打开新窗口查看\" 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]标记
       //处[H=x][/H]标记
       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 处理换行
       //处理换行,在每个新行的前面添加两个全角空格
       r = new Regex(@"(\r\n((&nbsp;)| )+)(?<正文>\S+)",RegexOptions.IgnoreCase);
       for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) 
       {
        sDetail = sDetail.Replace(m.Groups[0].ToString(),"<BR>  " + m.Groups["正文"].ToString());
       }
       //处理换行,在每个新行的前面添加两个全角空格
       sDetail = sDetail.Replace("\r\n","<BR>");
       #endregion
       return sDetail;
      }
      #endregion
     }
    }
      

  2.   

    把这个代码写到一个.cs文件里,添加到工程,然后在需要用这个类的页面引用
    using Test.Com;然后,比如数据库读出来的数据是str;
    那么
    string temp = UBB.UBBToHTML(str);把temp输出就好了
      

  3.   

    linsoo() ( 一级(初级)) 是正解
      

  4.   

    using Test.Com;
    你要使用的地方;声明
    string aa = UBB.UBBToHTML();
      

  5.   

    能不能给出引用页面的完整代码
    例如论坛发贴子时应用UBB功能的效果
      

  6.   

    哦,不好意思,我上面的邮箱留错了
    [email protected]
    我想做一个简单的页面:
                           主题
                           texbox
                           UBB功能模块
                           textbox
                           上传附件
                           提交
      

  7.   

    如果是vs2005,就选中app_code目录,如果不是任何目录都可.然后添加->现在文件,选中这个文件,就可.
    调用.
    stirng sHTML = Test.Com.UBB.UBBToHTML(输入的htmlstring);得到返回的sHTML
      

  8.   

    linsoo() ( 一级(初级)) 说的很正确呀
      

  9.   

    linsoo()  正解```就是一个using 就解决问题了``就可以调用了``
      

  10.   

    ASP.net C# 关于UBB的确一点写不出来,PB还能写几句
      

  11.   

    一方法:
    把这个类namespace Test.Com命名空间改为你程序的命名空间  如是vs2005,就添加到app_code文件夹中,然后就可以像你自己写的类一样进行实例化调用其中的方法.
    二方法: 
     把这个类生成一个.DDL文件,在你的程序中添加引用.再在程序中加上using Test.Com;就可以进行实例调用了.
      

  12.   

    UBB的代码不是已经有了....只需要你调用而已