IT码农库

您当前所在位置:首页 > 网络编程 > 正则表达式

正则表达式

得到连接和图片的地址 正则

互联网 2006-08-23正则表达式2800
复制代码 代码如下:function AddSiteURL(ByVal Str)   If IsNull(Str) Then       AddSiteURL = ""       Exit Function    End If  &nbs...
复制代码 代码如下:

function AddSiteURL(ByVal Str)
  If IsNull(Str) Then
      AddSiteURL = ""
      Exit Function 
  End If

  Dim re
  Set re=new RegExp
  With re
    .IgnoreCase =True
    .Global=True

    .Pattern="<img (.*?)src=""(?!(http|https)://)(.*?)"""
    str = .replace(str,"<img $1src=""" & SiteURL & "$3""")

    .Pattern="<a (.*?)href=""(?!(http|https|ftp|mms|rstp)://)(.*?)"""
    str = .replace(str,"<a $1href=""" & SiteURL & "$3""")
  End With
  Set re=Nothing

  AddSiteURL=Str
End Function
大图广告(830*140)