c# - How can I strip any and all HTML tags from a string? -


this question has answer here:

i have string defined so:

private const string refer_to_business = "<pre> (refer business office guidance , explain below circumstances exception policy or attach copy of request)</pre>"; 

...which has, can see, "pre" tag preserve space prepended verbiage. want to, though, reference string without "pre" tags. easy enough search "<pre>" , "</pre>" , remove them, become tedious every html tag type.

how can i, in c#, strip tags out of string, regardless of whether "<pre>", "<h1>", "<span>", "<aside>" or else?

try regex replacement. pattern matches html tags within string. here

        var pattern = @"</?\w+((\s+\w+(\s*=\s*(?:"".*?""|'.*?'|[^'"">\s]+))?)+\s*|\s*)/?>";         var source = "<pre> (refer business office guidance , explain below circumstances exception policy or attach copy of request)</pre>";         regex.replace(source, pattern, string.empty); 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -