Function BBcode(st As StyledText) As String //TODO [quote] Dim sr As StyleRun Dim i As Integer Dim buf, s As String Dim ret() As String Dim isCode, inCode As Boolean Dim rx as new RegEx rx.SearchPattern = "((ht|f)tps?://|mailto:)[\S]+" rx.ReplacementPattern = "\[url\]$&\[/url]" rx.Options.ReplaceAllMatches = True For i = 0 To st.StyleRunCount - 1 sr = st.StyleRun(i) buf = sr.Text isCode = InStr(0,sr.Font,"Courier") > 0 If isCode Then If inCode = False Then // start of code buf = "[code]" + buf End If ElseIf inCode Then //end of code ret.Append("[/code]") End If inCode = isCode If isCode = false Then buf = rx.Replace(buf) If sr.Bold Then buf = "[b]" + buf + "[/b]" If sr.Italic Then buf = "[i]" + buf + "[/i]" If sr.Underline Then buf = "[u]" + buf + "[/u]" If sr.Size <> 12 Then s = "[size=" + CStr(sr.Size)+"]" buf = s + buf + "[/size]" End If If sr.TextColor <> &c000000 Then s = CStr( sr.TextColor) s = Replace(s,"&h","#") s = "[color=" + s + "]" buf = s + buf + "[/color]" End If End If ret.Append(buf) Next i if inCode then ret.Append("[/code]") Return join(ret,"") End Function