C # (go, filter) line breaks in character drop

Source: Internet
Author: User
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:

  1. Replacing "/n/r" with "/r/r" or "/n/n" is not a function.
  2. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.