How can I remove “\r\n” from a string in C#? Can I use a regular expression?

前端 未结 8 1668
粉色の甜心
粉色の甜心 2020-12-04 23:16

I am trying to persist string from an ASP.NET textarea. I need to strip out the carriage return line feeds and then break up whatever is left into a string array of 50 chara

8条回答
  •  心在旅途
    2020-12-04 23:52

    The .Trim() function will do all the work for you!

    I was trying the code above, but after the "trim" function, and I noticed it's all "clean" even before it reaches the replace code!

    String input:       "This is an example string.\r\n\r\n"
    Trim method result: "This is an example string."
    

    Source: http://www.dotnetperls.com/trim

提交回复
热议问题