自动识别HTML的标记 替换连接
@L_360_0@ 代码如下:
%
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,"$1a 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,"$1a href=""http://$2"" target=""_blank"">
$2/a>
")
End If
End With
Set TempReg = Nothing
SenFe_UbbCode = sContent
End Function
%>
Function SenFe_UbbCode(sContent) Dim TempReg Set TempReg = New RegExp With TempReg .IgnoreCase = True .Global = True '自动识别网址 If InStr(Lcase(sContent),"http://")>
0 Then .Pattern = "(^|[^0 or InStr(Lcase(sContent),"bbs.")>
0 Then .Pattern = "(^|[^\/\\\w\=])((www|bbs)\.(\w)+\.([\w\/\\\.\=\?\+\-~`@\'!%#]|(&
))+)" sContent = .Replace(sContent,"$1$2") End If End With Set TempReg = Nothing SenFe_UbbCode = sContentEnd Function
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: 自动识别HTML的标记 替换连接
本文地址: https://pptw.com/jishu/595441.html