您现在的位置:首页 >> 电脑技术 >> 网页设计 >> 内容

asp自动识别URL网址链接的函数

时间:2009/8/23 0:50:07 点击:

Function autoLink(str)
 str=" "&str
 Set re=new regExp '建立正则表达式对象regular expression
 re.IgnoreCase=true '忽略大小写
 re.Global=true '搜索匹配字串针对全部文本
 '查找带协议前缀的链接
 re.Pattern="(http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?)"
 str=re.replace(str,"<a href='$1' target='_blank'>$1</a>")
 '查找不带协议前缀的链接
 re.Pattern="([^(http:\/\/)])(www\.([\w-]+\.)+[\w]+(\/[\w-]+)*[\/]?([\w-]+\.[\w]+)?(\?[\w]+=[\w]+(&[\w]+=[\w]+)*)?)"
 str=re.replace(str,"$1<a href='http://$2' target='_blank'>$2</a>")
 '查找邮件链接
 re.Pattern="(mailto:)?([\w]+@([\w-]+\.)+[\w]+)"
 str=re.replace(str,"<a href='mailto:$2'>$1$2</a>")
 Set re=nothing
 autolink=trim(str)
End Function

作者:不详 来源:网络
相关文章
  • 没有相关文章
共有评论 0相关评论
发表我的评论
  • 大名:
  • 内容:
  • 0759生活杂侃(www.0759gj.com) © 2024 版权所有 All Rights Reserved.
  • 公安备案:网监备4408013010516号 粤ICP备06030107号
  • Powered by laoy! V4.0.2

  • 部分文章来源于网络,若侵犯了您的权益请跟我们联系!