.Net实现的UBB类

369 2020-06-21
我是一只小可爱
[pre] using System; using System.Text.RegularExpressions; namespace ubb.Components {  ///  /// UBB 的摘要说明。  ///  public class UBB  {   private static string dvHTMLEncode(string fString)   {    if(fString!=string.Empty)    {     fString.Replace("<","<");     fString.Replace(">","&rt;");     fString.Replace(((char)34).ToString(), """);     fString.Replace(((char)39).ToString(), "'");     fString.Replace(((char)13).ToString(), "");     fString.Replace(((char)10).ToString(), "
");    }    return(fString);   }   public static string txtMessage(string str)   {    str = dvHTMLEncode(str);    if(str!="")    {     Regex my=new Regex(@"(/[IMG/])(.[^/[]*)(/[//IMG/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"按此在新窗口浏览图片screen.width-333)this.width=screen.width-333"">");     my=new Regex(@"/[DIR=*([0-9]*),*([0-9]*)/](.[^/[]*)/[//DIR]",RegexOptions.IgnoreCase);     str=my.Replace(str,@"");     my=new Regex(@"/[QT=*([0-9]*),*([0-9]*)/](.[^/[]*)/[//QT]",RegexOptions.IgnoreCase);     str=my.Replace(str,@"");     my=new Regex(@"/[MP=*([0-9]*),*([0-9]*)/](.[^/[]*)/[//MP]",RegexOptions.IgnoreCase);     str=my.Replace(str,@"");     my=new Regex(@"/[RM=*([0-9]*),*([0-9]*)/](.[^/[]*)/[//RM]",RegexOptions.IgnoreCase);     str=my.Replace(str,@"
");     my=new Regex(@"(/[FLASH/])(.[^/[]*)(/[//FLASH/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$2");     my=new Regex(@"(/[ZIP/])(.[^/[]*)(/[//ZIP/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"
点击下载该文件");     my=new Regex(@"(/[RAR/])(.[^/[]*)(/[//RAR/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"
点击下载该文件");     my=new Regex(@"(/[UPLOAD=(.[^/[]*)/])(.[^/[]*)(/[//UPLOAD/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"
此主题相关图片如下:
按此在新窗口浏览图片screen.width-333)this.width=screen.width-333"">");     my= new Regex(@"(/[URL/])(http:////.[^/[]*)(/[//URL/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$2");     my= new Regex(@"(/[ATT/])(http:////.[^/[]*)(/[//ATT/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"上传文件:$2");     my=new Regex(@"(/[URL/])(.[^/[]*)(/[//URL/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$2");     my=new Regex(@"(/[URL=(http:////.[^/[]*)/])(.[^/[]*)(/[//URL/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$3");     my=new Regex(@"(/[URL=(.[^/[]*)/])(.[^/[]*)(/[//URL/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$3");     my=new Regex(@"(/[EMAIL/])(/S+/@.[^/[]*)(/[//EMAIL/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$2");     my=new Regex(@"^(HTTP://[A-Za-z0-9/./=/?%/-&_~`@':+!]+)",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$1");     my=new Regex(@"(HTTP://[A-Za-z0-9/./=/?%/-&_~`@':+!]+)$",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$1");     my=new Regex(@"[^>=""](HTTP://[A-Za-z0-9/./=/?%/-&_~`@':+!]+)",RegexOptions.IgnoreCase);     str = my.Replace(str,@"$1");     my=new Regex(@"^(FTP://[A-Za-z0-9/./=/?%/-&_~`@':+!]+)",RegexOptions.IgnoreCase);      str = my.Replace(str,@"$1");     my= new Regex(@"(FTP://[A-Za-z0-9/./=/?%/-&_~`@':+!]+)$",RegexOptions.IgnoreCase);     str = my.Replace(str,@"$1");     my=new Regex(@"[^>=""](FTP://[A-Za-z0-9/.//=/?%/-&_~`@':+!]+)",RegexOptions.IgnoreCase);     str = my.Replace(str,@"$1");     my= new Regex(@"^(RTSP://[A-Za-z0-9/./=/?%/-&_~`@':+!]+)",RegexOptions.IgnoreCase);     str = my.Replace(str,@"$1");     my= new Regex(@"(RTSP://[A-Za-z0-9/./=/?%/-&_~`@':+!]+)$",RegexOptions.IgnoreCase);     str = my.Replace(str,@"$1");     my=new Regex(@"[^>=""](RTSP://[A-Za-z0-9/.//=/?%/-&_~`@':+!]+)",RegexOptions.IgnoreCase);     str = my.Replace(str,@"$1");     my=new Regex(@"^(MMS://[A-Za-z0-9/./=/?%/-&_~`@':+!]+)",RegexOptions.IgnoreCase);     str = my.Replace(str,@"$1");     my= new Regex(@"(MMS://[A-Za-z0-9/./=/?%/-&_~`@':+!]+)$",RegexOptions.IgnoreCase);     str = my.Replace(str,@"$1");     my=new Regex(@"[^>=""](MMS://[A-Za-z0-9/.//=/?%/-&_~`@':+!]+)",RegexOptions.IgnoreCase);     str = my.Replace(str,@"$1");     my=new Regex(@"(/[HTML/])(.[^/[]*)(/[//HTML/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"
以下内容为程序代码:
$2
");     my=new Regex(@"(/[CODE/])(.[^/[]*)(/[//CODE/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"
以下内容为程序代码:
$2
");     my=new Regex(@"(/[COLOR=(.[^/[]*)/])(.[^/[]*)(/[//COLOR/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$3");     my=new Regex(@"(/[FACE=(.[^/[]*)/])(.[^/[]*)(/[//FACE/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$3");     my=new Regex(@"(/[ALIGN=(.[^/[]*)/])(.*)(/[//ALIGN/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"
$3
");     my=new Regex(@"(/[QUOTE/])(.*)(/[//QUOTE/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"
$2

");     my=new Regex(@"(/[MOVE/])(.*)(/[//MOVE/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$2");     my=new Regex(@"/[GLOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)/](.[^/[]*)/[//GLOW]",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$4
");     my=new Regex(@"/[SHADOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)/](.[^/[]*)/[//SHADOW]",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$4
");     my=new Regex(@"(/[I/])(.[^/[]*)(/[//I/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$2");     my=new Regex(@"(/[U/])(.[^/[]*)(/[//U/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$2");     my=new Regex(@"(/[B/])(.[^/[]*)(/[//B/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$2");     my=new Regex(@"(/[FLY/])(.[^/[]*)(/[//FLY/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$2");     my=new Regex(@"(/[SIZE=1/])(.[^/[]*)(/[//SIZE/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$2");     my=new Regex(@"(/[SIZE=2/])(.[^/[]*)(/[//SIZE/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$2");     my=new Regex(@"(/[SIZE=3/])(.[^/[]*)(/[//SIZE/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$2");     my=new Regex(@"(/[SIZE=4/])(.[^/[]*)(/[//SIZE/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"$2");     my=new Regex(@"(/[CENTER/])(.[^/[]*)(/[//CENTER/])",RegexOptions.IgnoreCase);     str=my.Replace(str,@"
$2
");    }    return(str);       }  } } [/pre] [hr] 作者:mdot 来源:CSDN 原文: a(https://blog.csdn.net/mdot/article/details/181391 )[https://blog.csdn.net/mdot/article/details/181391 ] 版权声明:本文为博主原创文章,转载请附上博文链接!
回帖