用正则表达式来完成
类似这样做其它的标签就可以完在基本的UBB功能
呵呵,太懒了,写字日少
Function
DeLink(
ByVal
htmlText
As
String
)
As
String
'
进行A标签解码
Dim hrefRegex As New Regex( _
" [urls*=s*([^""]+)s*]([sS]*?)[/url] " , _
RegexOptions.IgnoreCase)
Dim output As String = ""
For Each m As Match In hrefRegex.Matches(htmlText)
htmlText = Replace (htmlText, m.Groups( 0 ).Value, " <a href="" " & m.Groups( 1 ).Value & " ""> " & m.Groups( 2 ).Value & " </a> " )
Next
Return htmlText
End Function
Function EnLink( ByVal htmlText As String ) As String ' 进行A标签编码
Dim hrefRegex As New Regex( _
" <A[^>]*?HREFs*=s*""([^""]+)""[^>]*?>([sS]*?)</A> " , _
RegexOptions.IgnoreCase)
Dim output As String = ""
For Each m As Match In hrefRegex.Matches(htmlText)
htmlText = Replace (htmlText, m.Groups( 0 ).Value, " [url= " & m.Groups( 1 ).Value & " ] " & m.Groups( 2 ).Value & " [/url] " )
Next
Return htmlText
End Function
Dim hrefRegex As New Regex( _
" [urls*=s*([^""]+)s*]([sS]*?)[/url] " , _
RegexOptions.IgnoreCase)
Dim output As String = ""
For Each m As Match In hrefRegex.Matches(htmlText)
htmlText = Replace (htmlText, m.Groups( 0 ).Value, " <a href="" " & m.Groups( 1 ).Value & " ""> " & m.Groups( 2 ).Value & " </a> " )
Next
Return htmlText
End Function
Function EnLink( ByVal htmlText As String ) As String ' 进行A标签编码
Dim hrefRegex As New Regex( _
" <A[^>]*?HREFs*=s*""([^""]+)""[^>]*?>([sS]*?)</A> " , _
RegexOptions.IgnoreCase)
Dim output As String = ""
For Each m As Match In hrefRegex.Matches(htmlText)
htmlText = Replace (htmlText, m.Groups( 0 ).Value, " [url= " & m.Groups( 1 ).Value & " ] " & m.Groups( 2 ).Value & " [/url] " )
Next
Return htmlText
End Function
类似这样做其它的标签就可以完在基本的UBB功能
呵呵,太懒了,写字日少