All pastes #11246 Raw Edit

Mine

public text v1 · immutable
#11246 ·published 2005-05-08 18:56 UTC
rendered paste body
function ReplaceSpaces(s: string): string;
var
  i: Integer;
  LastWasPlus: Boolean;
begin
  result := StringReplace(s, ' ', '+', [rfReplaceAll]);
  i := 1;
  LastWasPlus := false;
  while (i < Length(result)) do
  begin
    If result[i] = '+' then
    begin
      If LastWasPlus = true then
        delete(result, i, 1)
      else
      begin
        LastWasPlus := true;
        inc(i);
      end;
    end
    else
    begin
      LastWasPlus := false;
      inc(i);
    end;
  end;
end;

// Use: Edit1.Text := ReplaceSpaces(Edit1.Text);