Delphi : Metin içinde arama Fonksiyonu

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;

Yorum Yap


Not - Bunları KullanabilirsinizHTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">