delphi 判断文本是否包含多个关键词之一


本文整理自网络,侵删。

 
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Memo2: TMemo;
    Button1: TButton;
    Memo3: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function Check_keyword(const txt: string;keywordlist:tstringlist): Boolean;
var
  I: Integer;
begin
 Result :=false;
  keywordlist.beginUpdate;
for I := 0 to keywordlist.Count-1 do
begin
if pos(keywordlist.Strings[I],txt)>0 then
begin
Result :=true;
Break;
end;
end;
keywordlist.endUpdate;
end;


procedure TForm1.Button1Click(Sender: TObject);
var
key:tstringlist;
begin
key:=tstringlist.Create;
key.Text:=Memo1.Text;

Memo3.Clear;

if Check_keyword(Memo2.Text,key) then
begin
Memo3.Lines.Add('存在');
end
else
begin
Memo3.Lines.Add('不存在');
end;

end;

end.

相关阅读 >>

Delphi arp攻击代码

Delphi中string与pansichar转换

Delphi 实现卸载windows应用程序(类似360软件管家-卸载程序)

Delphi判断字符串是否为数字

pos、ansipos、fillchar在Delphi2010中unicode的问题

Delphi xe取得硬盘序列号代码 复制代码

Delphi的获取某坐标的颜色值

Delphi listbox自动获取列表框中的组件焦点

Delphi xe 使用savestate保存firemonkey状态的示例

Delphi string转unicode

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...