如题

解决方案 »

  1.   

    //例子,将str中的'd'替换为'o',如果要删除,将'o'改为''
    str:='rrrededeee';
      i:=pos('d',str);
      while i>0 do
      begin
        str:=copy(str,1,i-1)+'o'+copy(str,i+1,length(str)-i);
        i:=pos('d',str);
      end;
      edit1.text:=str;
      

  2.   

    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;DescriptionStringReplace replaces occurrences of the substring specified by OldPattern with the substring specified by NewPattern. StringReplace assumes that the source string, specified by S, may contain Multibyte characters.If the Flags parameter does not include rfReplaceAll, StringReplace only replaces the first occurrence of OldPattern in S. Otherwise, all instances of OldPattern are replaced by NewPattern.If the Flags parameter includes rfIgnoreCase, The comparison operation is case insensitive.
      

  3.   

    pos(s1,s2)   在s2字符串中找出第一个出现s1的第一个字符位置,如果找不到,返回0.
      

  4.   

    uses strUtils;
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      showMessage(ansiReplacetext('sourceString','s','|goomoo|'));
    end;