function PosEx(const Source, Sub: string; Index: Integer = 1): Integer; var I, J, K, L: Integer; T: string; begin Result := 0; T := Source; K := 0; L := Length(Sub); for I := 1 to Index do begin J := Pos(Sub, T); if J <= 0 then Exit; Delete(T, 1, J + L - 1); Inc(K, J + L - 1); end; Dec(K, L - 1); Result := K; end; { PosEx }
var
I, J, K, L: Integer;
T: string;
begin
Result := 0;
T := Source;
K := 0;
L := Length(Sub);
for I := 1 to Index do begin
J := Pos(Sub, T);
if J <= 0 then Exit;
Delete(T, 1, J + L - 1);
Inc(K, J + L - 1);
end;
Dec(K, L - 1);
Result := K;
end; { PosEx }