欢迎光临
我们一直在努力

为字符串中的网址加上链接的程序例子

建站超值云服务器,限时71元/月

function tolink(str)

dim re 正则表达式对象

dim strcontent

if isnull(str) then str=""

set re = new regexp 创建正则表达式对象

with re

.global = true 搜索应用于整个字符串

.ignorecase = true 搜索不区分大小写的

strcontent=str

***************************************************************

邮件地址链接自动设置

***************************************************************

.pattern="([\w]*)@([\w\.]*)"

strcontent=.replace(strcontent,"<a href=mailto:$1@$2>$1@$2</a> ")

***************************************************************

链接自动设置

***************************************************************

======根据要求再添加协议名称=======

dim d(3),i

d(0)="http"

d(1)="ftp"

d(2)="news"

d(3)="mms"

===================================

for i=0 to ubound(d)

.pattern=d(i) + ":\/\/([\w\.]*)"

strcontent=.replace(strcontent,"<a href=" + d(i) + "://$1 target=_blank>" + d(i) + "://$1</a> ")

next

***************************************************************

end with

set re=nothing

tolink=strcontent

end function

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 为字符串中的网址加上链接的程序例子
分享到: 更多 (0)

相关推荐

  • 暂无文章