Possible duplicate:
Removing carriage return and newline from end of line in C #
How to remove a carriage return at the end of a line. I already have Google, but I can’t find the code I need.
This is my current code:
return s.Replace ("\ n", ") .Replace (" \ r ",") .Replace ("\ r \ n", "") .Trim ();
but, of course, all replacements of the old character will be replaced.
I tried these:
trimming a public line (line s) {
string[] whiteSpace = {"\r", "\n", "\r\n"}; foreach(string ws in whiteSpace) { if (s.EndsWith(ws)) { s = s.Substring(0, s.Length - 1); } } return s;
}
but it doesn’t work for me, maybe I missed something or there is something wrong with my code
I am also trying to use regex, but I cannot get what I need.
I get a string from a text document and then wrap it to other documents.
I will be grateful for any help. Tnx
source share