Removing carriage return and new-line from the end of a string in c#

后端 未结 12 1127
终归单人心
终归单人心 2020-12-02 13:57

How do I remove the carriage return character (\\r) and the new line character(\\n) from the end of a string?

12条回答
  •  伪装坚强ぢ
    2020-12-02 14:41

    string k = "This is my\r\nugly string. I want\r\nto change this. Please \r\n help!";
    k = System.Text.RegularExpressions.Regex.Replace(k, @"\r\n+", " ");
    

提交回复
热议问题