29-09-14, 08:57 AM
السلام عليكم ورحمة الله وبركاته
وجدت دالة تقوم بتحويل البيبي كود الى اتش ام ال واريد ان اعكسها
وجدت دالة تقوم بتحويل البيبي كود الى اتش ام ال واريد ان اعكسها
كود :
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