如何把URL和邮件地址转换为超级链接?_编程10000问

Function InsertHyperlinks(inText)
Dim objRegExp, strBuf
Dim objMatches, objMatch
Dim Value, ReplaceValue, iStart, iEnd

  strBuf = ""
  iStart = 1
  iEnd = 1
  Set objRegExp = New RegExp

  objRegExp.Pattern = "\b(www|http|\S+@)\S+\b"  <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

' 判断URLs和emails.
  objRegExp.IgnoreCase = True                 

' 设置大小写不敏感..
  objRegExp.Global = True                     

' 全局适用.
  Set objMatches = objRegExp.Execute(inText)
  For Each objMatch in objMatches
    iEnd = objMatch.FirstIndex
    strBuf = strBuf & Mid(inText, iStart, iEnd-iStart+1)
    If InStr(1, objMatch.Value, "@") Then
      strBuf = strBuf & GetHref(objMatch.Value, "EMAIL", "_BLANK")
    Else
      strBuf = strBuf & GetHref(objMatch.Value, "WEB", "_BLANK")
    End If
    iStart = iEnd+objMatch.Length+1
  Next
  strBuf = strBuf & Mid(inText, iStart)
  InsertHyperlinks = strBuf
End Function

Function GetHref(url, urlType, Target)
Dim strBuf

  strBuf = "<a href="""
  If UCase(urlType) = "WEB" Then
    If LCase(Left(url, 3)) = "www" Then
      strBuf = "<a href=""URL:" & url & """超级链接:""" & _
              Target & """>" & url & "</a>"
    Else
      strBuf = "<a href=""" & url & """超级链接:""" & _
              Target & """>" & url & "</a>"
    End If
  ElseIf UCase(urlType) = "EMAIL" Then
    strBuf = "<a href=""电子邮件地址:" & url & """链接目标:""" & _
            Target & """>" & url & "</a>"
  End If
  GetHref = strBuf
End Function

 

 

[1]

时间: 2024-07-31 13:53:15

如何把URL和邮件地址转换为超级链接?_编程10000问的相关文章

jquery分析文本里url或邮件地址为真实链接的方法

  本文实例讲述了jquery分析文本里url或邮件地址为真实链接的方法.分享给大家供大家参考.具体如下: 这段代码可以分析出文本里的所有超级链接,包含邮件.url.#链接等等,并分别输出为真实链接地址 ? 1 2 3 4 5 6 7 8 9 10 11 $.fn.tweetify = function() { this.each(function() { $(this).html( $(this).html() .replace(/((ftp|http|https)://(w+:{0,1}w*

jquery分析文本里url或邮件地址为真实链接的方法_jquery

本文实例讲述了jquery分析文本里url或邮件地址为真实链接的方法.分享给大家供大家参考.具体如下: 这段代码可以分析出文本里的所有超级链接,包含邮件.url.#链接等等,并分别输出为真实链接地址 $.fn.tweetify = function() { this.each(function() { $(this).html( $(this).html() .replace(/((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/

如何用ASP发送html格式的邮件?_编程10000问

如何用ASP发送html格式的邮件? <% Dim objMail Set objMail = CreateObject("CDONTS.Newmail") objMail.TO = "sunchunliang@263.net" objMail.From =shenzhaoyang@intels.net objmail.Subject = "闪亮日子之html撼雪喷云" objMail.MailFormat = cdoMailFormatM

怎样避免直接在地址栏敲入URL即可绕过登录页的错误?_编程10000问

第一个办法:用两个文件来解决这个问题:userandpwd.asp和secretarticle.asp.前者只负责提供输入用户名和密码,由后者来完成验证工作.这样即使知道了asppwdrst.asp 所在的 URL,也决不会看到什么内容的. userandpwd.asp < html > < body > < form name="form1"action= "secretarticle.asp" method_ ="POST

如何验证IP地址?_编程10000问

 sub chkIP(boardid) dim rsIP dim ipArr dim ignored dim i dim ip dim sql ip=Request.ServerVariables("REMOTE_ADDR") ignored=false if not isempty(boardid) then sql="select ignoreip from board where boardid="&cstr(boardid) set rsIP=con

用asp实现网址和邮件地址的转换函数_应用技巧

网址和邮件地址的转换函数<% function URLconvert(str)  convertstr=str urlLocation=instr(convertstr,"http://") if (urlLocation=0) and (mailLocation=0) then  URLconvert=convertstr exit function end if if urlLocation<>0 then rightstr=str Do while urlLoc

asp.net获取URL和IP地址的方法汇总_实用技巧

HttpContext.Current.Request.Url.ToString() 并不可靠. 如果当前URL为 http://localhost/search.aspx?user=http://csharp.xdowns.com&tag=%BC%BC%CA%F5 通过HttpContext.Current.Request.Url.ToString()获取到的却是 http://localhost/search.aspxuser=http://csharp.xdowns.com&tag=

CSS定义Hover实现文字变大的超级链接_链接特效

移动鼠标到任意一个连接上则可放大显示该超连接. 超连接1 超连接2 超连接3

Dreamweaver网页制作教程:超级链接

  超级链接 作为网站肯定有很多的页面,如果页面之间彼此是独立的,那么网页就好比是孤岛,这样的网站是无法运行的.为了建立起网页之间的联系我们必须使用超级链接.称"超级链接",是因为它什么都能链接,如:网页.下载文件.网站地址.邮件地址--等等.下边我们就来讨论怎样在网页中创建超级链接. [页面之间的超级连接] 在网页中,单击了某些图片.有下划线或有明示链接的文字就会跳转到相应的网页中去. 1.在网页中选中要做超级链接的文字或者图片. 2.在属性面板中单击黄色文件夹图标,在弹出的对话框里