Linked Questions
35 questions linked to/from Replace Line Breaks in a String C#
2
votes
4
answers
30k
views
How to remove \n in a string? [duplicate]
How to remove \n in a string?
E.g.
Input : string s = "\n1234"
Output I want (but I can't achieve) : string s = "1234"
What I've tried (and failed) :
s.Remove(0,1);
s.Trim();
Additional notes :
I ...
2
votes
2
answers
9k
views
remove line breaks and white spaces [duplicate]
Possible Duplicate:
Replace Line Breaks in a String C#
hi I have an textarea which anyone can enter text, where they can put line breaks inside the text area.
How can I remove the line breaks ...
1
vote
1
answer
2k
views
Replace Next Line by <br> in the String Obtained from TextBox [duplicate]
I need to replace New Line with <br> in the string obtained from a text box.Currently i use this
string text= textbox.Text;
text.Replace(System.Environment.NewLine, "<br>");
But nothing ...
0
votes
1
answer
2k
views
Does .Net contain a built in Line Endings conversion which checking input format [duplicate]
I'm getting a string from an external native library function which uses "\n" for line separation. I simply want to write this to disk using the appropiate line ending format on the system I'...
1
vote
3
answers
1k
views
how to split string base on "\r\n" in c# when string value have "\r\n\r\n" [duplicate]
i have this string
var str="\r\nFeatures\r\nWins\r\n\r\n";
i want split on "\r\n" but between two "\r\n\r\n" have value null or whitespace
i want get result 3 items = Features Wins nullorwhitespace
...
-1
votes
2
answers
898
views
Line Break in C# String [duplicate]
I'm receiving a random line break in the following C# string and can't identify why the output is on two separate lines.
I've really only tried to define the variable in two different manners. Both ...
-3
votes
1
answer
190
views
Replace wordwrap of a Textbox [duplicate]
How can I replace the line break of a textbox (multiline-box) by the html's <br>?
This is my code:
string output = tb_Notizen.Text.Replace("\\r\\n", "<br>");
Whats wrong here?
I ...
0
votes
0
answers
76
views
How do I find and remove any rule or newline in an output? [duplicate]
I have written an app to compare the response I get for a request with its standard response. If they differ I need to find the difference. Since the response I get for the request has \r and \n in ...
51
votes
12
answers
66k
views
How to eliminate ALL line breaks in string?
I have a need to get rid of all line breaks that appear in my strings (coming from db).
I do it using code below:
value.Replace("\r\n", "").Replace("\n", "").Replace("\r", "")
I can see that there's ...
10
votes
6
answers
21k
views
Show new lines from text area in ASP.NET MVC
I'm currently creating an application using ASP.NET MVC. I got some user input inside a textarea and I want to show this text with <br />s instead of newlines. In PHP there's a function called ...
12
votes
5
answers
10k
views
What would be the fastest way to remove Newlines from a String in C#?
I have a string that has some Environment.Newline in it. I'd like to strip those from the string and instead, replace the Newline with something like a comma.
What would be, in your opinion, the ...
11
votes
2
answers
11k
views
Replace newlines with <p> paragraph and with <br /> tags
So I know how to replace newlines in my C# code. But replacing a newline for a <br /> tag isn't always very correct.
So I was wondering what kind of strategy do others use? The correct way I ...
5
votes
6
answers
22k
views
Loop over strings added to StringBuilder
I have the following code:
StringBuilder sb = new StringBuilder();
sb.Append("Ola");
sb.Append("Jola");
sb.Append("Zosia");
Can I iterate over StringBuilder object using for, or foreach?
Can I ...
1
vote
5
answers
10k
views
Dump text to file with line breaks
private void btnDump_Click(object sender, EventArgs e)
{
using (StreamWriter sw = new StreamWriter("E:\\TestFile.txt"))
{
// Add some text to the file.
sw.WriteLine(txtChange....
5
votes
3
answers
12k
views
C# remove extra carriage returns from Stream
Im reading file in as a stream: Stream fin = File.OpenRead(FilePath);
Is there any way how i would be able to find and remove all carriage returns from that file stream?
EDIT: The goal is to remove ...