Delphi如何获取一个字符串再另一个字符串中最后一次出现的位置

uses StrUtils;
 
function ReversePos(SubStr, S: String): Integer;
var
  i : Integer;
begin
  i := Pos(ReverseString(SubStr), ReverseString(S));
  if i > 0 then i := Length(S) - i - Length(SubStr) + 2;
  Result := i;
end;
 
 
调用的例子:
 
  ShowMessage (IntToStr(ReversePos( 'abc', 'abc123abc456')));

猜你喜欢

转载自www.cnblogs.com/linjincheng/p/11721390.html