欢迎来到代码驿站!

当前位置:首页 >

自动识别HTML的标记 替换连接

时间:2021-03-06 10:12:38|栏目:|点击:

复制代码 代码如下:

<%
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
%>




[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]

上一篇:js实现全屏漂浮广告移入光标停止移动

栏    目:

下一篇:Powershell小技巧之通过EventLog查看近期电脑开机和关机时间

本文标题:自动识别HTML的标记 替换连接

本文地址:http://www.codeinn.net/misctech/75443.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有