content=需要截取的字符串
b=查到到的开头(结果不包含他)
e=(左到右查到的第一次内容,结果不包含他)
asp我写法如下Function Getstr(content,b,e)
IF instr(content,b)<>0 or instr(content,e)<>0 then
w=instr(content,b)
getstrtemp=mid(content,w+len(b))
If instr(getstrtemp,e)-1>0 then getstr=left(getstrtemp,instr(getstrtemp,e)-1)
end if
End FunctionC#要怎么写呢
用来做(小偷)采集程序的
按开头与结尾截取出需要的内容!
各位大大帮忙!

解决方案 »

  1.   

    你查查IndexOf()和Substring()的用法
      

  2.   

       private string Getstr(string content,string b,string e)
            {
                int _StarIndex =content.IndexOf(b);
                if(_StarIndex==-1)return "";
                _StarIndex++;
                int _EndIndex =content.IndexOf(e,_StarIndex);
                if(_EndIndex==-1)return"";
                return content.Substring(_StarIndex,_EndIndex-_StarIndex);        }