求C#实现UBB Code功能的代码……

Not 2003-07-30 04:49:36
RT
一时急用找不到……
...全文
36 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
tmxk0000 2003-12-19
  • 打赏
  • 举报
回复

text = Regex.Replace(text, "\\[B\\](?<boldText>.*)\\[/B\\]",
"<b>${boldText}</b>", RegexOptions.IgnoreCase);
// 替换下划线
text = Regex.Replace(text, "\\[U\\](?<underlineText>.*)\\[/U\\]",
"<u>${underlineText}</u>", RegexOptions.IgnoreCase);
// 替换斜体
text = Regex.Replace(text, "\\[I\\](?<italicText>.*)\\[/I\\]",
"<i>${italicText}</i>", RegexOptions.IgnoreCase);

// 替换居中
text = Regex.Replace(text, "\\[center\\](?<centerText>.*)\\[/center\\]",
"<center>${centerText}</center>", RegexOptions.IgnoreCase);


// 替换超级链接
text = Regex.Replace(text, "\\[url=(?<url>.*)\\](?<urltext>.*)\\[/url\\]",
"<a href='${url}'target='_blank'>${urltext}</a>", RegexOptions.IgnoreCase);


// //[email]
text = Regex.Replace(text, "\\(?<txtText>.*)\\[/email\\]",
"<a href='mailto:${email}' target='_blank'>${txtText}</a><br/>", RegexOptions.IgnoreCase);



//[fly]
text = Regex.Replace(text, "\\[fly\\]",
"<marquee width=90% behavior=alternate scrollamount=3>", RegexOptions.IgnoreCase);
text = Regex.Replace(text, "\\[/fly\\]",
"</marquee>", RegexOptions.IgnoreCase);


//[move]
text = Regex.Replace(text, "\\[move\\]",
"<marquee scrollamount=3>", RegexOptions.IgnoreCase);
text = Regex.Replace(text, "\\[/move\\]",
"</marquee>", RegexOptions.IgnoreCase);

//[grow]
text = Regex.Replace(text, "\\[glow=(?<gwidth>.*)\\,(?<gcolor>.*)\\,(?<gsr>.*)\\](?<txtText>.*)\\[/glow\\]", "<table width=${gwidth} style='filter:glow(color=${gcolor}, strength=${gsr})'>${txtText}</table>", RegexOptions.IgnoreCase);
//
// //[shadow]
text = Regex.Replace(text, "\\[shadow=(?<gwidth>.*)\\,(?<gcolor>.*)\\,(?<gsr>.*)\\](?<txtText>.*)\\[/shadow\\]","<table width=${gwidth} style='filter:shadow(color=${gcolor}, strength=${gsr})'>${txtText}</table>", RegexOptions.IgnoreCase);
Not 2003-12-19
  • 打赏
  • 举报
回复
up

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧