BackPos function. Like pos but works Backwards.


BackPos function. Like pos but works Backwards.

It gives the position of first occurrance of a sub string in a string from the right instead of from then left in pos.


function BackPos(Substr: string; S: string): Integer;
var loop:integer;
    ch:string;
begin
  for loop:=length(s) downto 1 do
  begin
    ch:= copy(s,loop,length(substr));
    if ch=substr then
    begin
      backpos:=loop;
      exit;
    end;
  end;
end;

home