How to replace Html breaks with newline in C# and VB.NET

To replace Html breaks with newline in C# and VB.NET you can use the following snippet.

Sample C#

public static string HtmlBreaksToNewline(string input)
{
	return input.Replace("<br />", "\r\n");
}

public static string NewlineToHtmlBreaks(string input)
{
	return input.Replace("\r\n", "<br />");
}

Sample VB.NET

Public Shared Function HtmlBreaksToNewline(input As String) As String
	Return input.Replace("<br />", vbCr & vbLf)
End Function

Public Shared Function NewlineToHtmlBreaks(input As String) As String
	Return input.Replace(vbCr & vbLf, "<br />")
End Function

Please Share us:
Please rate this snippet

One thought on “How to replace Html breaks with newline in C# and VB.NET

Leave a Reply