ITPub博客

首页 > IT基础架构 > 网络安全 > 为字符串中的网址加上链接的程序例子 (转)

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

原创 网络安全 作者:gugu99 时间:2008-01-24 10:44:00 0 删除 编辑
为字符串中的网址加上链接的程序例子 (转)[@more@]

  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


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10748419/viewspace-998321/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    3121
  • 访问量
    2641570