Einzelnen Beitrag anzeigen

Bjoerk

Registriert seit: 28. Feb 2011
Ort: Mannheim
1.384 Beiträge
 
Delphi 10.4 Sydney
 
#44

AW: Leerzeichen in String einfügen

  Alt 2. Feb 2016, 07:41
Habt ihr die schon?
Delphi-Quellcode:
function InsertAfterEveryNthPos(const AStr, AInsertStr: string; const APos: integer): string;
var
  I, InsertCount: integer;
begin
  Result := '';
  if APos > 0 then
  begin
    InsertCount := Length(AStr) div APos;
    for I := 1 to InsertCount do
      Result := Result + Copy(AStr, APos * (I - 1) + 1, APos) + AInsertStr;
    if Length(AStr) mod APos <> 0 then
      Result := Result + Copy(AStr, InsertCount * APos + 1, Length(AStr) - InsertCount * APos);
  end;
end;
  Mit Zitat antworten Zitat