1.如果文件比较小的话,先用 StrUtils 单元的 ReverseString 函数反转字符串再用 Pos;<br>2.这是我根据 StrUtils 单元的 PosEx 查找函数改编的反方向 Pos 函数<br>function TForm1.PosReverse(const SubStr, S: String): Integer;<br>var<br> I,X: Integer;<br> Len, LenSubStr: Integer;<br>begin<br> LenSubStr := Length(SubStr);<br> Len := Length(S) - LenSubStr + 1;<br> i := Len;<br> while I > 0 do begin<br> if S = SubStr[1] then begin<br> X := 1;<br> while (X < LenSubStr) and (S[I + X] = SubStr[X + 1]) do<br> Inc(X);<br> if (X = LenSubStr) then begin<br> Result := I;<br> Exit;<br> end;<br> end;<br> Dec(I);<br> end;<br> Result := 0;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> Caption := IntToStr(PosReverse('11','11223311445'));<br>end;