asp提取文档中的附件链接
2012-05-24 金城 1861
<%
Dim regEx,str1,s
str1 = html &""
s=""
Set regEx = New RegExp
regEx.Pattern = "<(img|a)[^>]*(src|href)\s?=['""]?[^\s>'""]*\.("&ext&")['""]?[^>]*>"
''response.Write("<br>" ®Ex.pattern)
regEx.IgnoreCase = True
regEx.Global = True
set Matches = regEx.execute(str1)
for each match in Matches
s = s &"|" ®ExReplace(match.value,"<.*(src|href)\s?=['""]?([^\s>'""]*)['""]?[^>]*>$","$2")
next
set Matches=nothing
if s="" then
PickAttachment=Empty
else
s=regExReplace(s,"^\|","")
PickAttachment=split(s,"|")
end if
end function
if isArray(attachmentArr) then
for each att in attachmentArr
'' TODO
next
end if
%>
'' 提取文档中的附件链接,返回数组
function PickAttachment(html,ext)Dim regEx,str1,s
str1 = html &""
s=""
Set regEx = New RegExp
regEx.Pattern = "<(img|a)[^>]*(src|href)\s?=['""]?[^\s>'""]*\.("&ext&")['""]?[^>]*>"
''response.Write("<br>" ®Ex.pattern)
regEx.IgnoreCase = True
regEx.Global = True
set Matches = regEx.execute(str1)
for each match in Matches
s = s &"|" ®ExReplace(match.value,"<.*(src|href)\s?=['""]?([^\s>'""]*)['""]?[^>]*>$","$2")
next
set Matches=nothing
if s="" then
PickAttachment=Empty
else
s=regExReplace(s,"^\|","")
PickAttachment=split(s,"|")
end if
end function
'' 使用方法
attachmentArr=PickAttachment(content,"gif|bmp|jpg|rar|doc|png|swf|zip|docx")if isArray(attachmentArr) then
for each att in attachmentArr
'' TODO
next
end if
%>
- 上一篇:FTP的主动模式和被动模式(PORT/PASV)
- 下一篇:碉堡了