I am getting a raw string of data, and I dont want to allow more than 2 new lines, I have no control over the source however I only want to show end of current line, and one gap line in any scenario, I can't work out a nice solution to do so.
Here is an example of the data:
"content": "Ldfjljildjbfd\r\n\r\nEihile\r\n\r\n\r\n\r\n\r\n\r\nErlgheiorjgoierjhg\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\neighi\r\n"
Here is an example of how it looks on the screen currently:
This is my example
It doesn't look particularly appealing
And here is an example of how I would like it to look:
This is my example
Much better here...
I've tried to do this in the dirtiest way possible, using something like this:
private string DirtyLineClean(string body)
{
string body1 = body.Replace(@"\r\n\r\n\r\n\r\n\r\n\r\n", "\r\n\r\n");
string body2 = body1.Replace(@"\r\n\r\n\r\n\r\n\r\n", "\r\n\r\n");
string body3 = body2.Replace(@"\r\n\r\n\r\n\r\n", "\r\n\r\n");
string body4 = body3.Replace(@"\r\n\r\n\r\n", "\r\n\r\n");
return body4;
}
Unfortunately that doesn't work at all.
Any suggestions welcome.
UPDATE
Using LarsTech answer, something isn't quite working. Here is my input:
Ldjgehgoierg\r\n\r\nErg\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nGergege\r\n\r\n\r\n\r\nErgerg\r\n\r\nEg\r\n\r\nEr\r\n\r\nGer\r\n\r\n\r\n\r\n\r\n\r\nrgg\r\n
Here is the output:
Ldjgehgoierg\r\n\n\r\n\nErg\r\n\n\r\n\n\r\n\n\r\n\n\r\n\n\r\n\n\r\n\n\r\n\nGergege\r\n\n\r\n\n\r\n\n\r\n\nErgerg\r\n\n\r\n\nEg\r\n\n\r\n\nEr\r\n\n\r\n\nGer\r\n\n\r\n\n\r\n\n\r\n\n\r\n\n\r\n\nrgg\r"