17 May 2010

Conversione di codice html in testo piano

Piccolo e utile frammento di codice che, utilizzando le amate/odiate espressioni regolari, ripulisce dai tag html il testo passato.

 

Imports System.Text
Imports System.Text.RegularExpressions
		
Function Html2Text(ByVal html As String) As String
 
   Dim repattern As String = “\<[^\>]*\>“
   Dim rexp As New Regex(repattern, RegexOptions.IgnoreCase)

    html = rexp.Replace(html, String.Empty)

   Return html
End Function