Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove \r from string

Tags:

string

c#

I have some Html in string I have tried utmost to remove \r many times but fails.

text.Replace("\r\n", "").Replace("\r", "").Replace("\n", "");
like image 394
Afnan Bashir Avatar asked Dec 20 '10 19:12

Afnan Bashir


People also ask

How do I remove a symbol from a string in R?

How to remove a character or multiple characters from a string in R? You can either use R base function gsub() or use str_replace() from stringr package to remove characters from a string or text.

How do you remove the RN from the strings?

Try this. text = text . Replace("\\r\\n", "");

How do I remove an RN from a string in Python?

Use the str. rstrip() method to remove \r\n from a string in Python, e.g. result = my_str. rstrip() .

What are \n \r called?

Adding Newline Characters in a String. Operating systems have special characters denoting the start of a new line. For example, in Linux a new line is denoted by “\n”, also called a Line Feed. In Windows, a new line is denoted using “\r\n”, sometimes called a Carriage Return and Line Feed, or CRLF.


1 Answers

You need to assign the result back to text, like:

text = text.Replace("\r\n", "").Replace("\r", "").Replace("\n", "");
like image 67
Klaus Byskov Pedersen Avatar answered Sep 20 '22 11:09

Klaus Byskov Pedersen