/// <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("&", "&amp;");
tString = tString.Replace(">", "&gt;");
tString = tString.Replace("<", "&lt;");
tString = tString.Replace("\"", "&quot;");
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;
}

最新文章

  1. Ajax及跨域
  2. ps通道磨皮
  3. 使用Mac的AppleScritp调用控制台的方式
  4. Codeforces Bubble Cup 8 - Finals [Online Mirror] D. Tablecity 数学题
  5. 批量修改数据sql
  6. 谈谈python 中__name__ = &#39;__main__&#39; 的作用
  7. OD: Vulnerabilities Analyze Skills
  8. ruby on rails创建的页面訪问很慢
  9. R语言数据分析系列六
  10. var d = document.getElementById 错误
  11. CC2530入门教程-02】CC2530的通用I/O端口输入和输出控制
  12. java,http的post和get
  13. java中的BigDecimal和String的相互转换,int和String的类型转换,Integer类和String相互转换
  14. moment.js 学习笔记
  15. MongoDB 之 $关键字 及 $修改器 $set $inc $push $pull $pop MongoDB - 4
  16. FileReader类和FileWriter类的基本用法示例
  17. codeforces 869A/B/C
  18. 基于udp的套接字
  19. ThinkPHP的A方法,R方法,M方法,D方法区别
  20. 超酷的Android 侧滑(双向滑动菜单)效果

热门文章

  1. 深度探索C++对象模型之第一章:关于对象之对象的差异
  2. 使用FastJson转化Json格式
  3. AM8互联设置方法
  4. LR调试脚本的时候报错Error -27796:(已解决)
  5. 阿里云在云栖大会发布SaaS加速器3.0版最新成果,让天下没有难做的SaaS
  6. JS typeof() parseInt() parseFloat()
  7. Failed to read artifact descriptor for org.springframework.cloud:spring-cloud-starter-config:jar:unk
  8. 学SpringBoot一篇就够了
  9. Pycharm VS VS Code(个人使用感受)
  10. python代码打包成exe文件