Asp教程

通过asp实例结合结合ACCESS,MSSQL来更好的深入Asp学习 - 爬坡者

« FSO操作示例asp文件操作函数详解 »

ASP为字符串中的网址自动加上链接

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,"$1@$2 ")
'***************************************************************
'链接自动设置
'***************************************************************
'======根据要求再添加协议名称=======
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,"" + D(I) + "://$1 ")
Next
'***************************************************************
End With
Set RE=Nothing
ToLink=strContent
End Function

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最新评论及回复

最近发表

Powered By Z-Blog 1.8 Spirit Build 80710

Copyright 2007-2008 papozhe.com [asp教程] All Rights Reserved.
浙ICP备07030537号
免责申明:所有文章除特别声明,均来自网上,主要为学习用!内容仅供参考,版权归原作者。如侵犯您利益,请来信告知.
Email:papozhe$Gmail.com QQ:76336503