先替换空格,再调用UBB替换。

解决方案 »

  1.   

    另外你怎么解决
    kkk这样的情况的?
      

  2.   

    谢谢ifengfeng(fengfeng) ,我的问题解决了。你的问题kkk:你看看我的代码:把和分开替换、分开替换,其他的依此类推。
    Regex my=new Regex(@"(\[URL=)(.[^\[]*)(\])",RegexOptions.IgnoreCase);
    str=my.Replace(str,@"<A HREF=""$2"" TARGET=_blank>");
                my=new Regex(@"(\[\/URL\])",RegexOptions.IgnoreCase);
                str=my.Replace(str,@"</A>");
    my=new Regex(@"(\[B\])",RegexOptions.IgnoreCase);
    str=my.Replace(str,@"<b>");
    my=new Regex(@"(\[U\])",RegexOptions.IgnoreCase);
    str=my.Replace(str,@"<u>");
    my=new Regex(@"(\[I\])",RegexOptions.IgnoreCase);
    str=my.Replace(str,@"<i>");
    my=new Regex(@"(\[\/B\])",RegexOptions.IgnoreCase);
    str=my.Replace(str,@"</b>");
    my=new Regex(@"(\[\/U\])",RegexOptions.IgnoreCase);
    str=my.Replace(str,@"</u>");
    my=new Regex(@"(\[\/I\])",RegexOptions.IgnoreCase);
    str=my.Replace(str,@"</i>");
    my=new Regex(@"(\[COLOR=)(.[^\[]*)(\])",RegexOptions.IgnoreCase);
    str=my.Replace(str,@"<font color=""$2"">");
    my=new Regex(@"(\[\/COLOR\])",RegexOptions.IgnoreCase);
    str=my.Replace(str,@"</font>");