想针对Memo控件中的文本进行查找替换,如何实现?

解决方案 »

  1.   

    用pos函数做
    for I:=0 to memo1.lines.count do
    begin
      posreturn:=pos(finddialog1.findtext,Memo1.lines[I]);
      if Posreturn<>0 then{找倒了}
      begin
        。。
      end
      
    end;
      

  2.   

    要实现替换,用ReplaceDialog做代码差不多
      

  3.   

    StringReplace
    用这个函数可以解决问题Returns a string with occurrences of one substring replaced by another substring.UnitSysutilsCategorystring handling routinestype
      TReplaceFlags = set of (rfReplaceAll, rfIgnoreCase);
    function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;