Uses strutils;
function CountStr(const ASearchFor, ASearchIn : string) : Integer; var Start : Integer; begin Result := 0; Start := Pos(ASearchFor, ASearchIn); while Start > 0 do begin Inc(Result); Start := PosEx(ASearchFor, ASearchIn, Start + 1); end; end;
procedure TForm1.btn1Click(Sender: TObject); var sonuc:integer; metin:string; begin metin:= 'Merhaba dünya!'; sonuc := CountStr('dünya', metin); // sonuç 1; sonuc := CountStr('Nerede?', metin); // sonuç 0; end;
0 Yorumlar.