Tuesday, April 6, 2010

Clean up html code and words tag in .NET

Private Shared Function CleanHTML(ByVal html As String) As String
html = Regex.Replace(html, "<[/]?(font|span|xml|del|ins|[ovwxp]:\w+)[^>]*?>", "", RegexOptions.IgnoreCase)
html = Regex.Replace(html, "<([^>]*)(?:class|lang|style|size|face|[ovwxp]:\w+)=(?:'[^']*'|""[^""]*""|[^\s>]+)([^>]*)>", "<$1$2>", RegexOptions.IgnoreCase)
html = Regex.Replace(html, "<([^>]*)(?:class|lang|style|size|face|[ovwxp]:\w+)=(?:'[^']*'|""[^""]*""|[^\s>]+)([^>]*)>", "<$1$2>", RegexOptions.IgnoreCase)
Return html
End Function

3 comments:

Anonymous said...

What is the use of this code?

Anonymous said...

top [url=http://www.001casino.com/]casino[/url] check the latest [url=http://www.realcazinoz.com/]casino bonus[/url] free no set aside bonus at the foremost [url=http://www.baywatchcasino.com/]redeem casino
[/url].

International Toll Free Number said...

Fabulous, what a website it iѕ! This web ѕite ρresents valuable information to us, κeep it up.