Remove carriage return from string

前端 未结 9 2099
逝去的感伤
逝去的感伤 2021-01-03 17:41

I would like to insert the following into a string

some text here

some text here

some text here

9条回答
  •  天涯浪人
    2021-01-03 18:18

    How about using a Regex?

    var result = Regex.Replace(input, "\r\n", String.Empty)
    

    If you just want to remove the new line at the very end use this

    var result = Regex.Replace(input, "\r\n$", String.Empty)
    

提交回复
热议问题