将UBB编码转成标准的HTML代码
/// <summary>
/// 将UBB编码转成标准的HTML代码
/// </summary>
/// <param name="argString"></param>
/// <returns></returns>
public static string HtmlDecode(string argString)
{
string tString = argString;
if (tString != "")
{
Regex tRegex;
bool tState = true;
tString = tString.Replace("&", "&");
tString = tString.Replace(">", ">");
tString = tString.Replace("<", "<");
tString = tString.Replace("\"", """);
tString = Regex.Replace(tString, @"\[br\]", "<br />", RegexOptions.IgnoreCase);
string[,] tRegexAry = {
{@"\[p\]([^\[]*?)\[\/p\]", "$1<br />"},
{@"\[b\]([^\[]*?)\[\/b\]", "<b>$1</b>"},
{@"\[i\]([^\[]*?)\[\/i\]", "<i>$1</i>"},
{@"\[u\]([^\[]*?)\[\/u\]", "<u>$1</u>"},
{@"\[ol\]([^\[]*?)\[\/ol\]", "<ol>$1</ol>"},
{@"\[ul\]([^\[]*?)\[\/ul\]", "<ul>$1</ul>"},
{@"\[li\]([^\[]*?)\[\/li\]", "<li>$1</li>"},
{@"\[code\]([^\[]*?)\[\/code\]", "<div class=\"ubb_code\">$1</div>"},
{@"\[quote\]([^\[]*?)\[\/quote\]", "<div class=\"ubb_quote\">$1</div>"},
{@"\[color=([^\]]*)\]([^\[]*?)\[\/color\]", "<font style=\"color: $1\">$2</font>"},
{@"\[hilitecolor=([^\]]*)\]([^\[]*?)\[\/hilitecolor\]", "<font style=\"background-color: $1\">$2</font>"},
{@"\[align=([^\]]*)\]([^\[]*?)\[\/align\]", "<div style=\"text-align: $1\">$2</div>"},
{@"\[url=([^\]]*)\]([^\[]*?)\[\/url\]", "<a href=\"$1\">$2</a>"},
{@"\[img\]([^\[]*?)\[\/img\]", "<img src=\"$1\" />"}
};
while (tState)
{
tState = false;
for (int ti = 0; ti < tRegexAry.GetLength(0); ti++)
{
tRegex = new Regex(tRegexAry[ti, 0], RegexOptions.IgnoreCase);
if (tRegex.Match(tString).Success)
{
tState = true;
tString = Regex.Replace(tString, tRegexAry[ti, 0], tRegexAry[ti, 1], RegexOptions.IgnoreCase);
}
}
}
}
return tString;
}
最新文章
- Ajax及跨域
- ps通道磨皮
- 使用Mac的AppleScritp调用控制台的方式
- Codeforces Bubble Cup 8 - Finals [Online Mirror] D. Tablecity 数学题
- 批量修改数据sql
- 谈谈python 中__name__ = &#39;__main__&#39; 的作用
- OD: Vulnerabilities Analyze Skills
- ruby on rails创建的页面訪问很慢
- R语言数据分析系列六
- var d = document.getElementById 错误
- CC2530入门教程-02】CC2530的通用I/O端口输入和输出控制
- java,http的post和get
- java中的BigDecimal和String的相互转换,int和String的类型转换,Integer类和String相互转换
- moment.js 学习笔记
- MongoDB 之 $关键字 及 $修改器 $set $inc $push $pull $pop MongoDB - 4
- FileReader类和FileWriter类的基本用法示例
- codeforces 869A/B/C
- 基于udp的套接字
- ThinkPHP的A方法,R方法,M方法,D方法区别
- 超酷的Android 侧滑(双向滑动菜单)效果
热门文章
- 深度探索C++对象模型之第一章:关于对象之对象的差异
- 使用FastJson转化Json格式
- AM8互联设置方法
- LR调试脚本的时候报错Error -27796:(已解决)
- 阿里云在云栖大会发布SaaS加速器3.0版最新成果,让天下没有难做的SaaS
- JS typeof() parseInt() parseFloat()
- Failed to read artifact descriptor for org.springframework.cloud:spring-cloud-starter-config:jar:unk
- 学SpringBoot一篇就够了
- Pycharm VS VS Code(个人使用感受)
- python代码打包成exe文件