Registriert seit: 19. Apr 2005
Ort: Hückeswagen
335 Beiträge
Delphi 11 Alexandria
|
AW: Schnelle Wildcart Suche
31. Jul 2020, 12:09
Derzeit Suche ich so:
Code:
function MatchText(const aSubText, aText: string): Boolean;
var
pSource: PChar;
pPattern: PChar;
function _MatchPattern(aElement, aPattern: PChar): Boolean;
begin
if 0 = StrComp(aPattern, '*') then
Result := true
else if (aElement^ = Chr(0)) and (aPattern^ <> Chr(0)) then
Result := False
else if aElement^ = Chr(0) then
Result := true
else
begin
case aPattern^ of
'*':
if _MatchPattern(aElement, @aPattern[1]) then
Result := true
else
Result := _MatchPattern(@aElement[1], aPattern);
'?':
Result := _MatchPattern(@aElement[1], @aPattern[1]);
else
if aElement^ = aPattern^ then
Result := _MatchPattern(@aElement[1], @aPattern[1])
else
Result := False;
end;
end;
end;
begin
pSource := PChar(aText);
pPattern := PChar(aSubText);
Result := _MatchPattern(pSource, pPattern);
end;
Oliver
|
|
Zitat
|