欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-04-14 20:33:17
'================================================== '函数名:getbody '作  用:截取字符串...
'==================================================
'函数名: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