C# Replace <br> with \n: How to Convert HTML Line Breaks to Newlines
In C#, you can replace all occurrences of "
", "
", and "
" with "\n" (newline character) using the Replace method. Here's an example:
string input = \"This is a sample text.<br>Here is a new line.<br />Another line.<br/>\";
string output = input.Replace(\"<br>\", \"\n\")
.Replace(\"<br />\", \"\n\")
.Replace(\"<br/>\", \"\n\");
Console.WriteLine(output);
Output:
This is a sample text.
Here is a new line.
Another line.
原文地址: https://www.cveoy.top/t/topic/pv8e 著作权归作者所有。请勿转载和采集!