当前位置:首页 > ASP教程 > 应用技巧

GetBody asp实现截取字符串的代码

'==================================================
'函数名:getbody
'作  用:截取字符串
'参  数:constr ------将要截取的字符串
'参  数:startstr ------开始字符串
'参  数:overstr ------结束字符串
'参  数:inclul ------是否包含startstr
'参  数:inclur ------是否包含overstr
'==================================================
function getbody(constr,startstr,overstr,inclul,inclur)
   if constr="$false$" or constr="" or isnull(constr)=true or startstr="" or isnull(startstr)=true or overstr="" or isnull(overstr)=true then
      getbody="$false$"
      exit function
   end if
   dim constrtemp
   dim start,over
   constrtemp=lcase(constr)
   startstr=lcase(startstr)
   overstr=lcase(overstr)
   start = instrb(1, constrtemp, startstr, vbbinarycompare)
   if start<=0 then
      getbody="$false$"
      exit function
   else
      if inclul=false then
         start=start+lenb(startstr)
      end if
   end if
   over=instrb(start,constrtemp,overstr,vbbinarycompare)
   if over<=0 or over<=start then
      getbody="$false$"
      exit function
   else
      if inclur=true then
         over=over+lenb(overstr)
      end if
   end if
   getbody=midb(constr,start,over-start)
end function
【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!