前台传了一个字符串过来  发现里面换行符是\\n  而不是 \n  我替换不管用 , trim()也无济于事  求教

解决方案 »

  1.   


                string s = @"//a//b"; ;
                s = s.Replace(@"//", @"/");
      

  2.   

    str = str.Replace("\\\\n", "\\n");
      

  3.   

    str = str.Replace("\\\\n", "\\n");
      

  4.   


     string str = "sgateaf\\nadfadfadf\\n";
                string strT = str.Replace("\\n", "\n");vs2010上测试没问题。
      

  5.   

    JsonObject json1 = new JsonObject();
                        json1.setAttribute("sourceLine", temp);
                        string Name = sourceName.Replace("\\\\n", "\\n");
                        
                        json1.setAttribute("sourceName", Name.Trim());
    付给JSON  前台
      

  6.   

    string Name = sourceName.Replace("\\\\n", "\n");
    这样试试
      

  7.   


    楼主是想看到换行的文本而不是用\n分隔的文本吧,替换成行行就行啦。正则:html=Regex.Replace(html,@"\\\\n","\n");ok!
      

  8.   


    这里应该有你的解决方案!http://topic.csdn.net/u/20100424/14/9fe2ccb0-fcb3-4e0b-89a2-a89df62b6ac8.html