Hallo,
wenn man meine
Funktion anpasst und nur den ersten Teil verwendet, sollte das auch funktionieren.
Ungefähr so:
Delphi-Quellcode:
function FindMultiple(const Source: AnsiString;
const Patterns: array of AnsiString;
CaseSensitive: Boolean = True): Boolean;
type
TPattern = record
S: AnsiString;
L: Integer;
end;
var
C: Integer;
FPatterns: array of TPattern;
PatternCount: Integer;
PNum: Integer;
SourceLength: Integer;
SearchSource: AnsiString;
begin
// Is there anything to find at all?
if (Source = '') or (Length(Patterns) = 0) then
begin
Result := False;
Exit;
end;
PatternCount := Length(Patterns);
SetLength(FPatterns, PatternCount);
for C := 0 to PatternCount - 1 do
begin
if CaseSensitive then
FPatterns[C].S := Patterns[C]
else
FPatterns[C].S := AnsiLowerCase(Patterns[C]);
FPatterns[C].L := Length(Patterns[C]);
end;
if CaseSensitive then
SearchSource := Source
else
SearchSource := AnsiLowerCase(Source);
Result := True;
try
SourceLength := Length(Source);
C := 1;
while C <= SourceLength do
begin
for PNum := 0 to PatternCount - 1 do
begin
// Check first char before we waste a jump to CompareMem
if (SearchSource[C]) = (FPatterns[PNum].S[1]) then
begin
if CompareMem(@SearchSource[C], @FPatterns[PNum].S[1], FPatterns[PNum].L) then
Exit;
end;
end;
Inc(C);
end;
finally
// Clean up
Finalize(FPatterns);
end;
Result := False;
end;
Gruß
xaromz