public static String FindStrbetween(String S ,String Find1 , String Find2) { String R=""; int ID1=0; int ID2=0; int ID3=0; ID1=S.indexOf(Find1);if (ID1==-1){ return ""; } ID2=ID1+Find1.length();ID3=S.indexOf(Find2, ID2 );if (ID3==-1){ return ""; }R=S.substring( ID2 ,ID3);return R; }========以下是VB6的函数:'[简介]:'查找字符串间隔于Function FindStrBetween(bystr As String, findstr As String, findstr2 As String, Optional startid As Long = 1, Optional findinaddress As Long)'[mycode_id:536],edittime:2007-8-30 6:31:38'查找字符'startid从第几个开始On Error Resume Next'findstrbetweenDim id1 As Long, ID2 As LongDim Str As StringStr = bystr'MsgBox strid1 = InStr(startid, Str, findstr)If id1 = 0 Then Exit FunctionID2 = InStr(id1 + Len(findstr), Str, findstr2)'新改11-11If ID2 = 0 Then Exit FunctionFindStrBetween = Mid(Str, id1 + Len(findstr), ID2 - id1 - Len(findstr))findinaddress = id1End FunctionPRivate Sub Command1_Click()MsgBox FindStrBetween("我是中国人", "我是", "人")'计算结果是:中国End Sub
新闻热点
疑难解答