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

时间:2022-09-30 14:16:24
  1. '==================================================  
  2. '函数名:GetBody  
  3. '作  用:截取字符串  
  4. '参  数:ConStr ------将要截取的字符串  
  5. '参  数:StartStr ------开始字符串  
  6. '参  数:OverStr ------结束字符串  
  7. '参  数:IncluL ------是否包含StartStr  
  8. '参  数:IncluR ------是否包含OverStr  
  9. '==================================================  
  10. Function GetBody(ConStr,StartStr,OverStr,IncluL,IncluR)  
  11.    If ConStr="$False$" or ConStr="" or IsNull(ConStr)=True Or StartStr="" or IsNull(StartStr)=True Or OverStr="" or IsNull(OverStr)=True Then  
  12.       GetBody="$False$"  
  13.       Exit Function  
  14.    End If  
  15.    Dim ConStrTemp  
  16.    Dim Start,Over  
  17.    ConStrTemp=Lcase(ConStr)  
  18.    StartStr=Lcase(StartStr)  
  19.    OverStr=Lcase(OverStr)  
  20.    Start = InStrB(1, ConStrTemp, StartStr, vbBinaryCompare)  
  21.    If Start<=0 then  
  22.       GetBody="$False$"  
  23.       Exit Function  
  24.    Else  
  25.       If IncluL=False Then  
  26.          Start=Start+LenB(StartStr)  
  27.       End If  
  28.    End If  
  29.    Over=InStrB(Start,ConStrTemp,OverStr,vbBinaryCompare)  
  30.    If Over<=0 Or Over<=Start then  
  31.       GetBody="$False$"  
  32.       Exit Function  
  33.    Else  
  34.       If IncluR=True Then  
  35.          Over=Over+LenB(OverStr)  
  36.       End If  
  37.    End If  
  38.    GetBody=MidB(ConStr,Start,Over-Start)  
  39. End Function