如果你的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); }}
评论