Ver Mensaje Individual
  #3  
Antiguo 12-10-2015
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Reputación: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
A ver si ésta (recorre una sóla vez la cadena):

Código Delphi [-]
function ComprimeEspacios(S: String): String;
var
  I: Integer;

begin
  I := 1;

  while I <= Length(S) do
  begin
    while (I <= Length(S)) and (S[i] <> ' ') do
      Inc(I);

    Inc(I);

    while (I <= Length(S)) and (S[i] = ' ') do
      Delete(S, I, 1);

    Inc(I);
  end;

  Result := S;
end;

// Saludos
Responder Con Cita