能不能, String可以自动的替换掉, 不用其它比较麻烦的方法, 谢谢.

解决方案 »

  1.   

    是 HTML转义吧? 个人觉得 去掉不好 应该转义 另外 HTML的转义字符也就那几个撒。。
      

  2.   

      public static string InputText(string text, int maxLength) {
                text = text.Trim();
                if (string.IsNullOrEmpty(text))
                    return string.Empty;
                if (text.Length > maxLength)
                    text = text.Substring(0, maxLength);
                text = Regex.Replace(text, "[\\s]{2,}", " "); //two or more spaces
                text = Regex.Replace(text, "(<[b|B][r|R]/*>)+|(<[p|P](.|\\n)*?>)", "\n"); //<br>
                text = Regex.Replace(text, "(\\s*&[n|N][b|B][s|S][p|P];\\s*)+", " "); //&nbsp;
                text = Regex.Replace(text, "<(.|\\n)*?>", string.Empty); //any other tags
                text = text.Replace("'", "''");
                return text;
            }
      

  3.   


                string str = "&lt;&quot;slfks;uf&nbsp;&quot;&amp;&gt;";
                Console.WriteLine(Regex.Replace(str, @"\&[^;]*;", ""));//这只是去除的,没有替换成相应的字符
    /*
    输出:
    slfks;uf
    */
      

  4.   

    HttpUtility.HtmlDecode转下,就OK了