var x:TStrings;
i:integer;
begin
x:=TStringList.Create;//这就是字符串数组
x.add('abc');
x.Add('bcd');
x.Add('cde');
x.Add('def');
for i:=low(x) to high(x) do
begin
if pos('ab',x[i])>0 then//假定ab是要寻找的字符串
showmessage('success')
else showmessage('fail');
end;
//字符串匹配函数
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;
//寻找与目标字符串最匹配的字符串
function MaxMatchStr(DestStr:String;Strs:array of String):String;
var
I:Integer;
begin
Result:='';
for I:=1 to Length(Strs) do
//如果与目标匹配
if (Pos(Strs[I],DestStr)>0) and
//而且比现在找到的结果更长
(Length(Strs[I])>Length(Result)) then
//替换当前结果
Result:=Strs[I];
end;