モナーの *やさしい* Delphi質問スレ Ver.5
■ このスレッドは過去ログ倉庫に格納されています
0212DELモナ
NGNGfunction Like(Str,Ptn:string):Boolean;
var
P,I:Integer;
N:string;
begin
Result := False; N := ''; P := 1; I := 1;
if Str = '' then Exit; if Ptn = '' then Exit;
while (P <= Length(Ptn)) and (Ptn[P]='*') do Inc(P);
while (I <= Length(Str)) and (P <= Length(Ptn))do begin
if Ptn[P] = '[' then begin
N := ''; Inc(P);
while (P <= Length(Ptn)) and (Ptn[P] <> ']') do begin N := N + Ptn[P]; Inc(P); end;
end;
if N <> '' then begin
if Pos( Str[I], N )>0 then begin Inc(P); N := ''; end
end
else
if Ptn[P] = '?' then Inc(P)
else begin
if Ptn[P] = '*' then Inc(P);
if Ptn[P] = Str[I] then Inc(P);
end;
Inc(I);
end;
Result := (P > Length(Ptn)) and (I > Length(Str) );
{ Ptn が含まれているかどうかを調べるには以下の結果を使う }
{ Result := P > Length(Ptn); }
end;
■ このスレッドは過去ログ倉庫に格納されています