1 2 3 4
public static string StripHtmlComments(string html) { if (html == null) ...
C# On Strip Html Comments
by Jeff Atwood,
November 16, 2009 04:25
1 2 3 4
// ** DO NOT USE ** // THIS IS BAD BROKEN CODE, ONLY DISPLAYED FOR BENCHMARKING PURPOSES! if (!tagpaired[i] && !ignoredtags.Contains(tagname)) ...
1 2 3 4
var ignoredtags = new List<String> { "p", "img", "br" }; if (!tagpaired[i] && !ignoredtags.Contains(tagname)) ...
1 2 3 4
private static Regex _namedtags = new Regex (@"</?(?<tagname>\w+)[^>]*(\s|$|>)", RegexOptions.Singleline | RegexOptions.ExplicitCapture | RegexOptions.Compiled); ...
C# Balance HTML Tags
For the subset of HTML tags...
1 2 3 4
private static Regex _tags = new Regex("<[^>]*(>|$)", RegexOptions.Singleline | RegexOptions.ExplicitCapture | RegexOptions.Compiled); private static Regex _whitelist = new Regex(@" ...
C# Sanitize HTML
Takes a provided HTML strin...
That "invalid HTML tag" cas...