In the web application development we often need to strip HTML tags from the string that comes from input boxes.
This code snippet will strip a string of all Html tags and replace a tag with a blank space (You can alternatively replace it with String.Empty but this often leads to words being joined).
1: using System.Text.RegularExpressions;
2:
3: const string HTML_TAGS = "<.*?>";
4:
5: static string StripHTML (string inputString)
6: {
7: return Regex.Replace(inputString, HTML_TAGS , " ");
8: }
Enjoy Programming …
bfb06466-5a11-47c3-8102-e50f8f277a3c|0|.0
Categories:
C#, ASP.NET
23. January 2012
Tags: