Usuwanie niepotrzebnych spacjii + bajery

0

No to mam taki problem: chce usunąć niepotrzebne spacje tylko pominąć tekst oznaczony w " ... na przyklad :

[code]Ala ma kota "a kot ma ale"[/code]

i ma wyjść :

[code]Ala ma kota "a kot ma ale"[/code]

PS. przydał by sie kod lub dokładny opis [wstyd]

0

Co do opuszczania spacji to jest artykol na 4p

0
  i := 1;
  while i < Length(Lancuch) do
  begin
    case Lancuch[i] of
    '"':
      while Lancuch[i] <> '"' do
        Inc(i);
    ' ':
      if Lancuch[i-1] = ' ' then
      begin
        Delete(Lancuch, i, 1);
        Dec(i);
      end;
    end;
    Inc(i);
  end;

/* To działa już dobrze. */

0

Twoje dryobates sie wiesza :-P

Sheitar napisal takie coś :

function UsunSpacje(Txt: String): String;
var
 L: TStringList;
 S: String;
 n: Integer;
 F: Boolean;
begin
 L:=TStringList.Create;
 F:=False;
  if Txt[Length(txt)]<>'"' then Txt:=Txt+'"';
 while Pos('"',Txt)>0 do
  begin
   S:=Txt;
   Delete(S,Pos('"',Txt),Length(Txt));
   if not F then L.Add(S) else L.Add('"'+S+'"');
   F:=not F;
   Delete(Txt,1,Pos('"',Txt));
  end;
 Result:='';
 for n:=0 to L.Count-1 do
  begin
   S:=L.Strings[n];
   if S[1]<>'"' then
    begin
     while Pos('  ',S)>0 do
      begin
       Delete(S,Pos('  ',S),1);
      end;
     L.Strings[n]:=S;
    end;
   Result:=Result+L.Strings[n];
  end;
 L.Free;
end;

i na razie ładnie działa ;p

0
function usun_spacje(text : string): string;
var
temp : string;
p : integer;
c : byte;
begin
temp := '';
for p := 1 to length(text) do
     begin
            if (text[p] = '"') and (c = 1) then c := 0 else
            if (text[p] = '"') and (c = 0) then c := 1;
       if c = 1 then temp := temp + text[p] else
       if text[p] <> ' ' then temp := temp + text[p];
     end;
result := temp;
end;

1 użytkowników online, w tym zalogowanych: 0, gości: 1