当前位置: 移动技术网 > IT编程>开发语言>Asp > asp之GetArray提取链接地址,以$Array$分隔的代码

asp之GetArray提取链接地址,以$Array$分隔的代码

2017年12月12日  | 移动技术网IT编程  | 我要评论
'==================================================
'函数名:getarray
'作  用:提取链接地址,以$array$分隔
'参  数:constr ------提取地址的原字符
'参  数:startstr ------开始字符串
'参  数:overstr ------结束字符串
'参  数:inclul ------是否包含startstr
'参  数:inclur ------是否包含overstr
'==================================================
function getarray(byval constr,startstr,overstr,inclul,inclur)
on error resume next
   if constr="$false$" or constr="" or isnull(constr)=true or startstr="" or overstr="" or  isnull(startstr)=true or isnull(overstr)=true then
      getarray="$false$"
      exit function
   end if
   dim tempstr,tempstr2,objregexp,matches,match,templisturl
   tempstr=""
   set objregexp = new regexp 
   objregexp.ignorecase = true 
   objregexp.global = true
   objregexp.pattern = "("&startstr&").+?("&overstr&")"
   set matches =objregexp.execute(constr) 
   for each match in matches
      if templisturl =match.value then
      else
      tempstr=tempstr & "$array$" & match.value
      templisturl=match.value
      end if
   next 
   set matches=nothing

   if tempstr="" then
      getarray="$false$"
      exit function
   end if
   tempstr=right(tempstr,len(tempstr)-7)
   if inclul=false then
      objregexp.pattern =startstr
      tempstr=objregexp.replace(tempstr,"")
   end if
   if inclur=false then
      objregexp.pattern =overstr
      tempstr=objregexp.replace(tempstr,"")
   end if
   set objregexp=nothing
   set matches=nothing

   tempstr=replace(tempstr,"""","")
   tempstr=replace(tempstr,"'","")
   tempstr=replace(tempstr," ","")
   'tempstr=replace(tempstr,"(","")
   'tempstr=replace(tempstr,")","")

   if tempstr="" then
      getarray="$false$"
   else
      getarray=tempstr
   end if
end function

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网