基本信息
源码名称:bbcode 转换成 html 示例源码(亲测通过) discuz 帖子可用
源码大小:2.43M
文件格式:.zip
开发语言:C#
更新时间:2014-07-18
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

如果你的bbcode含中文 需将这里改下:


        public static System.Text.RegularExpressions.Regex OptionRegex
        {
            get
            {
                //return new System.Text.RegularExpressions.Regex(@"(?<Property>[\w]*)[\s]*=[\s]*(?<Value>[\x25\w/\:/.-]*)", RegexOptions.Compiled);      
               
                string strExp = @"(?<Property>[\w]*)[\s]*=[\s]*(?<Value>[\x25\w\s\S/\:/.-]*)";
                return new System.Text.RegularExpressions.Regex(strExp, RegexOptions.Compiled);      
            }
        } 




using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BBCode;
using BBCode.Collections;
using BBCode.Nodes;
using BBCode.Tags;
using BBCodeTestWebsite.SampleCode;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Parser parser = new Parser( new TagCollection()
                                                    {
                                                        SmileyTagFactory.Smile
                                                    },
                                    new TagCollection()
                                        {
                                            BBCodeTagFactory.Bold,
                                            BBCodeTagFactory.Italic,
                                            BBCodeTagFactory.Underline,
                                            BBCodeTagFactory.Strike,
                                            BBCodeTagFactory.Code,
                                            BBCodeTagFactory.H1,
                                            BBCodeTagFactory.H2,
                                            BBCodeTagFactory.H3,
                                            BBCodeTagFactory.Preformated,
                                            BBCodeTagFactory.Quote,
                                            BBCodeTagFactory.Align,
                                            BBCodeTagFactory.Color,
                                            BBCodeTagFactory.Size,
                                            BBCodeTagFactory.Url,
                                            BBCodeTagFactory.List,
                                            BBCodeTagFactory.Youtube,
                                            BBCodeTagFactory.HorizontalRuler,
                                            BBCodeTagFactory.Image,
                                            BBCodeTagFactory.Thumbnail,
                                            BBCodeTagFactory.Font,
                                            BBCodeTagFactory.Flash,
                                            BBCodeTagFactory.BackColor
                                        });

        ParseResult result = parser.Parse(txtInput.Text);

        htmlResults.InnerHtml = result.Print();
        txtResults.Text = Server.HtmlEncode(htmlResults.InnerHtml);

        INode node = result.GetFirst(BBCodeTagFactory.Bold);
        node = result.GetFirst(BBCodeTagFactory.Italic);
    }
}