How to strip html tags from string in C# and VB.NET

To strip html tags from string in C# and VB.NET you can use the following snippet.

Sample C#

public string StripHtmlTags (string input)
{
	string pattern = "<.*?>";
	return Regex.Replace (input, pattern, string.Empty);
}

Sample VB.NET

Public Function StripHtmlTags(input As String) As String
	Dim pattern As String = "<.*?>"
	Return Regex.Replace(input, pattern, String.Empty)
End Function

Please Share us:
Please rate this snippet

One thought on “How to strip html tags from string in C# and VB.NET

Leave a Reply