请问各位,在比较两字符串是否包含相同的字符的时候,是采用什么办法来做的.
本人见到,有直接用"=="的,我以前使用该方式,但是跟踪代码的时候发现,不能的出正确的结果.所以我现在采用函数来比较.但是我现在看到很多程序员使用"==".
请发表各位发表高见!
另请各位到下面的贴子中接分:
http://expert.csdn.net/Expert/topic/2499/2499416.xml?temp=.83099
http://expert.csdn.net/Expert/topic/2276/2276636.xml?temp=.4068872
如有高见请发表

解决方案 »

  1.   

    The following example uses two edit controls and a button on a form. When the button is clicked, the text in the edit controls is compared.uses SysUtils;
    procedure TForm1.Button1Click(Sender: TObject);var
      Msg: string;
      CompResult: Integer;
    begin
      Msg := Edit1.Text;
      CompResult := StrComp(PChar(Edit1.Text), PChar(Edit2.Text));
      if CompResult < 0 then
        Msg := Msg + ' is less than '
      else if CompResult > 0 then
        Msg := Msg + ' is greater than '
      else
        Msg := Msg + ' is equal to '
      Msg := Msg + Edit2.Text;
      ShowMessage(Msg);
    end;
      

  2.   

    可以用函数
      StringReplace()
      

  3.   

    str1,str2:string;for i:=1 to length(str1) do 
    begin
       if pos(str1[i],str2)>0 then 
          showmessage('有相同字符:'+str1[i]);
    end;
      

  4.   

    别忘了大小写统一
    LowerCase()
      

  5.   

    严重同意gencan(无敌) 
    用pos
      

  6.   

    支持gencan(无敌)
    pos很好的方法
      

  7.   

    字符串操作最常用的函数pos/copy/stringreplace,组合起来就可以了,算法太多了
      

  8.   

    copy+pos,stringreplace实际上也就是copy+pos