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 @ 与 ^ 运算符

Delphi的goto语句

Delphi 外壳扩展创建快捷方式和获取快捷方式的目标对象

Delphi 使用钩子函数 - 钩子链和 callnexthookex 的返回值

Delphi 窗体的位置和高宽度-tform:letf、top、width、height、clientwidth、clientheight

Delphi adoquery查询更改用户

Delphi实现拖动无标题窗口的5种方法

Delphi中的memo顶部添加行

Delphi case 语句中使用字符串

Delphi判断字符串中是否包含汉字,并返回汉字位置

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



打赏

取消

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

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

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

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

评论

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