S1='teh',S2='this is blue'
现在要求把S2里的删除掉S1内含有的字符得到S3='is is blu'请问如何实现?

解决方案 »

  1.   

    var i,j:integer;
        S1,S2,S3:string;
        Same:boolean;
    begin
      S1:='teh';S2:='this is blue';
      S3:='';
      for i:=1 to length(S2) do
        begin
          Same:=False;
          for j:=1 to length(S1) do
           if S2[i]=S1[j] then
              begin
                Same:=True;
                break;
              end;
          if not Same then S3:=S3+S2[i];
        end;
      ShowMessage(S3);
    end;
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      a, b, c: string;
      i: integer;
    begin
      a := 'this is blue';
      b := 'teh';
      for i:=1 to Length(b) do
        a := StringReplace(a, b[i], '', [rfReplaceAll]);
      ShowMessage(a);
    end;