用下面的函数,把这个字符串转化成一个数组,然后直接按照数组下标进行读取就可以了<br> TWords = array of String;<br><br>function SplitWithString(const S: String; SepStr: String): TWords;<br><br>implementation<br><br>function FindStr(const S, SX: String; var iStart, iEnd: Integer): Integer;<br>var<br> iMatch: Integer;<br> Len: Integer;<br>begin<br> Result := 0;<br> iMatch := 1;<br> Len := Length(SX);<br> while iStart <= iEnd do<br> begin<br> if S[iStart] = SX[iMatch] then<br> begin<br> iMatch := iMatch + 1;<br> if iMatch > Len then<br> begin<br> iStart := iStart + 1;<br> Result := iStart - iMatch + 1;<br> Break;<br> end;<br> end<br> else if iMatch > 1 then<br> begin<br> iStart := iStart - iMatch + 1;<br> iMatch := 1;<br> end;<br> iStart := iStart + 1;<br> end;<br>end;<br><br><br>function SplitWithString(const S: String; SepStr: String): TWords;<br>var<br> i, Len: Integer;<br> m, n: Integer;<br> ct: Integer;<br>begin<br> Len := Length(S);<br> i := 1;<br> ct := 0;<br> while i <= Len do<br> begin<br> m := i;<br> n := FindStr(S, SepStr, i, Len);<br> if n = 0 then n := Len + 1;<br> if n > m then<br> begin<br> SetLength(Result, ((ct + 10) div 10) * 10);<br> Result[ct] := Copy(S, m, n - m);<br> ct := ct + 1;<br> end;<br> end;<br> SetLength(Result, ct);<br>end;<br>