>>39
    p:=0;
    cnt:=0;
    str:=Memo1.Text;
    len:=length(sword);

    repeat
        ap:=Pos(sword, copy(str, p, High(Integer)));
        if ap>0 then
        begin
            p:=p+ap;
            Inc(cnt);
            Inc(p, len);
        end;
    until ap=0;
    ShowMessage(IntToStr(cnt));