Category: Strings
Title: Return the position of the last occurence of a substring in String
Date added: 15.03.2006
Hits: 1688
function LastPos(SubStr, S: string): Integer;
var
Found, Len, Pos: integer;
begin
Pos := Length(S);
Len := Length(SubStr);
Found := 0;
while (Pos > 0) and (Found = 0) do
begin
if Copy(S, Pos, Len) = SubStr
then
Found := Pos;
Dec(Pos);
end;
LastPos := Found;
end;