最好给个例子谢谢!在线等待~!

解决方案 »

  1.   

    给你个函数
    //字符串匹配函数
    function MatchToken(var Buffer: Pchar; const MatchStr: string): Boolean;
    var
      Token: Pchar;
    begin
      Token := Pchar(MatchStr);
      while Buffer^ <> #0 do
      begin
        if UpCase(Buffer^) = Token^ then
          inc(Token)
        else if Token <> Pchar(MatchStr) then
        begin
          Token := Pchar(MatchStr);
          if UpCase(Buffer^) = Token^ then
            inc(Token);
        end;
        inc(Buffer);
        if Token^ = #0 then
          Break;
      end;
      Result := Token^ = #0;
    end;
      

  2.   

    以下是判断memo第一行是否有字符串'you',楼主可以参考一下var
      str,tempstr: string;
      i: integer;
      bflag: boolean;
    begin
      bflag := false;
      str := trim(memo.Lines[0]);
      for i := 1 to memo.Lines.Count do
      begin
        tempstr := Copy(str, i, 3);
        if UpperCase(tempstr) = 'YOU' then//查找  'YOU'字符串
        begin
          bflag := true;
          break;
        end else Continue;
      end;  if bflag then
      showmessage('找到字串') else showmessage('字串找不到');
    end;