自动识别HTML的标记 替换连接
人气:0想了解自动识别HTML的标记 替换连接的相关内容吗,在本文为您仔细讲解的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:自动识别HTML的标记,替换连接,正则,下面大家一起来学习吧。
复制代码 代码如下:
<%
Function SenFe_UbbCode(sContent)
Dim TempReg
Set TempReg = New RegExp
With TempReg
.IgnoreCase = True
.Global = True
'自动识别网址
If InStr(Lcase(sContent),"http://")>0 Then
.Pattern = "(^|[^<=""])(http:(\/\/|\\\\)(([\w\/\\\+\-~`@:%])+\.)+([\w\/\\\.\=\?\+\-~`@\':!%#]|(&)|&)+)"
sContent = .Replace(sContent,"$1<a href=""$2"" target=""_blank"">$2</a>")
End If
'自动识别www等开头的网址
If InStr(Lcase(sContent),"www.")>0 or InStr(Lcase(sContent),"bbs.")>0 Then
.Pattern = "(^|[^\/\\\w\=])((www|bbs)\.(\w)+\.([\w\/\\\.\=\?\+\-~`@\'!%#]|(&))+)"
sContent = .Replace(sContent,"$1<a href=""http://$2"" target=""_blank"">$2</a>")
End If
End With
Set TempReg = Nothing
SenFe_UbbCode = sContent
End Function
%>
加载全部内容