在Delphi中搜索一个String数组
发布时间:2020-12-15 10:09:33 所属栏目:大数据 来源:网络整理
导读:在Delphi标准库中是否有一个功能来搜索字符串数组以获得特定的值? 例如 someArray:=TArraystring.Create('One','Two','Three');if ArrayContains(someArray,'Two') then ShowMessage('It contains Two'); 解决方法 绝对没有必要重新发明车轮. StrUtils.Matc
在Delphi标准库中是否有一个功能来搜索字符串数组以获得特定的值?
例如 someArray:=TArray<string>.Create('One','Two','Three'); if ArrayContains(someArray,'Two') then ShowMessage('It contains Two'); 解决方法
绝对没有必要重新发明车轮.
StrUtils.MatchStr做这个工作.
procedure TForm1.FormCreate(Sender: TObject); var someArray: TArray<string>; begin someArray:=TArray<string>.Create('One','Three'); if MatchStr('Two',someArray) then ShowMessage('It contains Two'); end; 注意参数顺序约定. 另一个注意事项:MatchStr是Delphi 7和Delphi 2007之间分配给此函数的规范化名称.历史名称为AnsiMatchStr(约定与RTL的其余部分相同:区分大小写的Str / Text后缀,MBCS的Ansi前缀/地点) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |