HTML to BB code Converter
http://social.msdn.microsoft.com/Forums/is/vbgeneral/thread/cb2da3c5-b938-4e74-9df9-c5996f481f60
Public Function ConvertHTML2BB(ByVal html As String) As String Try 'Define regex Dim regExp As Regex 'Regex for URL tag without anchor regExp = New Regex("\[url\]([^\]]+)\[\/url\]") html = regExp.Replace(html, "<a href=""$1"">$1</a>") 'Regex for URL with anchor regExp = New Regex("\[url=([^\]]+)\]([^\]]+)\[\/url\]") html = regExp.Replace(html, "<a href=""$1"">$2</a>") 'Image regex regExp = New Regex("\[img\]([^\]]+)\[\/img\]") html = regExp.Replace(html, "<img src=""$1"" />") 'Bold text regExp = New Regex("\[b\](.+?)\[\/b\]") html = regExp.Replace(html, "<b>$1</b>") 'Italic text regExp = New Regex("\[i\](.+?)\[\/i\]") html = regExp.Replace(html, "<i>$1</i>") 'Underline text regExp = New Regex("\[u\](.+?)\[\/u\]") html = regExp.Replace(html, "<u>$1</u>") 'Font size regExp = New Regex("\[size=([^\]]+)\]([^\]]+)\[\/size\]") html = regExp.Replace(html, "<span style=""font-size: $1px"">$2</span>") 'Font color regExp = New Regex("\[color=([^\]]+)\]([^\]]+)\[\/color\]") html = regExp.Replace(html, "<span style=""color: $1"">$2</span>") Return html Catch ex As Exception Return Nothing Debug.Print(ex.ToString) End Try End Function