This class provides common HTML helper functions working with text
Namespace:
CA.Common.TextAssembly: CA.Common (in CA.Common.dll) Version: 1.0.0.0 (1.0.0.0)
Remarks
//Source code from the Code Associate C# code library, Full documentation and latest updates can be found //@ http://www.codeassociate.com/caapi/ using System.Text.RegularExpressions; namespace CA.Common.Text { public static class HtmlHelper { public static string RemoveHtmlComments(string input) { if (!string.IsNullOrEmpty(input)) { // using a non greedy regex to get all the html or xml style comments out of the text Regex htmlCommentStripper = new Regex("(<!--((?!-->).)*-->)", RegexOptions.Singleline); return htmlCommentStripper.Replace(input, string.Empty); } else { // the string is null or is empty so just return the string as is.. return input; } } public static string RemoveHtmlTags(string input, string tagToRemove) { if (!string.IsNullOrEmpty(input)) { string regexexp = string.Format(@"<{0}>.*</{0}>", tagToRemove); // using a non greedy regex to get all the html or xml style comments out of the text Regex htmlCommentStripper = new Regex(regexexp, RegexOptions.Singleline); return htmlCommentStripper.Replace(input, string.Empty); } else { // the string is null or is empty so just return the string as is.. return input; } } } }