Text: C # (go, filter) line breaks in characters
Original address: http://www.feedou.com/articlepickservlet?commandkey=singlearticle&articleID= 5c42b75f1b435084011b49ba083217d4
The methods described in this article need to import namespaces first:usingSystem.Text.RegularExpressions;
- All newline characters in the string are removed: Textstr = Regex.Replace (Textstr, @ "[/n/r]", "");
- Remove the line break at the end: Textstr = Textstr.trimend ((char[]) "/N/R". ToCharArray ());
Attention:
- Replacing "/n/r" with "/r/r" or "/n/n" is not a function.
- As explained by MSDN,/n is a newline character/ R is a carriage return, and a text file stipulates that/r/n is used under Windows for line breaks, while Unix may have only/n
Another: When you generate line-wrapping text, you need to add "/r/n" after each line of text to achieve line wrapping.
C # (go, filter) line breaks in character drop