Guckst du hier:
Delphi-Quellcode:
function Like(const AString, APattern: String): Boolean;
var
StringPtr, PatternPtr: PChar;
StringRes, PatternRes: PChar;
begin
Result:=false;
StringPtr:=PChar(AString);
PatternPtr:=PChar(APattern);
StringRes:=nil;
PatternRes:=nil;
repeat
repeat
case PatternPtr^ of
#0: begin
Result:=StringPtr^=#0;
if Result or (StringRes=nil) or (PatternRes=nil) then
Exit;
StringPtr:=StringRes;
PatternPtr:=PatternRes;
Break;
end;
'*': begin
inc(PatternPtr);
PatternRes:=PatternPtr;
Break;
end;
'?': begin
if StringPtr^=#0 then
Exit;
inc(StringPtr);
inc(PatternPtr);
end;
else begin
if StringPtr^=#0 then
Exit;
if StringPtr^<>PatternPtr^ then begin
if (StringRes=nil) or (PatternRes=nil) then
Exit;
StringPtr:=StringRes;
PatternPtr:=PatternRes;
Break;
end
else begin
inc(StringPtr);
inc(PatternPtr);
end;
end;
end;
until false;
repeat
case PatternPtr^ of
#0: begin
Result:=true;
Exit;
end;
'*': begin
inc(PatternPtr);
PatternRes:=PatternPtr;
end;
'?': begin
if StringPtr^=#0 then
Exit;
inc(StringPtr);
inc(PatternPtr);
end;
else begin
repeat
if StringPtr^=#0 then
Exit;
if StringPtr^=PatternPtr^ then
Break;
inc(StringPtr);
until false;
inc(StringPtr);
StringRes:=StringPtr;
inc(PatternPtr);
Break;
end;
end;
until false;
until false;
end;
Das hab ich hier mal irgendwo im Forum gefunden ..