| 1:2:
 3:
 4:
 5:
 6:
 7:
 8:
 9:
 10:
 11:
 12:
 13:
 14:
 15:
 16:
 17:
 18:
 19:
 20:
 21:
 22:
 23:
 24:
 25:
 26:
 27:
 28:
 29:
 30:
 31:
 32:
 33:
 34:
 35:
 36:
 37:
 38:
 39:
 40:
 41:
 42:
 43:
 44:
 45:
 46:
 47:
 48:
 49:
 50:
 51:
 52:
 53:
 54:
 55:
 56:
 57:
 58:
 59:
 60:
 61:
 62:
 63:
 64:
 65:
 66:
 67:
 68:
 69:
 70:
 71:
 72:
 73:
 74:
 75:
 76:
 77:
 78:
 79:
 80:
 81:
 82:
 83:
 84:
 85:
 86:
 87:
 88:
 89:
 90:
 91:
 92:
 
 | function check_klammern(ostr : String) : Boolean;var i,k : Integer;
 begin
 k := 0;
 for i := 1 to length(ostr) do
 begin
 if ostr[i] = '(' then k := k + 1;
 if ostr[i] = ')' then k := k - 1;
 end;
 if k = 0 then Result := True
 else Result := False;
 if ((Pos('(',ostr) = 0) and (Pos(')',ostr) = 0)) then Result := False;
 end;
 
 function log_suche_and(log_str, str : String) : Boolean;
 var log_str_parts : TStringDynArray;
 i : Integer;
 begin
 log_str_parts := Explode(' AND ',log_str);
 i := 0;
 Result := True;
 while ((i <= High(log_str_parts)) and (Result = True)) do
 begin
 if Pos(log_str_parts[i], str) = 0 then Result := False;
 i := i + 1;
 end;
 end;
 
 function log_suche_or(log_str, str : String) : Boolean;
 var log_str_parts : TStringDynArray;
 i : Integer;
 begin
 log_str_parts := Explode(' OR ',log_str);
 i := 0;
 Result := False;
 while ((i <= High(log_str_parts)) and (Result = False)) do
 begin
 if Pos(log_str_parts[i], str) <> 0 then Result := True;
 i := i + 1;
 end;
 end;
 
 function get_lgstr_part1(log_str : String) : Integer;
 var i : Integer;
 begin
 i := 1;
 while ((i <= length(log_str)) and ((copy(log_str,i,5) <> ' AND ') or (copy(log_str,i,4) <> ' OR ')) and (not check_klammern(copy(log_str,1,i)))) do
 i := i + 1;
 Result := i;
 end;
 
 function get_lgstr_part2(log_str : String) : Integer;
 var i : Integer;
 begin
 i := length(log_str);
 while ((i >= 1) and ((copy(log_str,i-5,5) <> ' AND ') or (copy(log_str,i-4,5) <> ' OR ')) and (not check_klammern(copy(log_str,i,length(log_str))))) do
 i := i - 1;
 Result := i;
 end;
 
 function log_suche(log_str, str : String) : Boolean;
 var str_p1, str_p2 : Integer;
 begin
 if ((log_str[1] = '(') or (log_str[length(log_str)] = ')')) then
 begin
 if log_str[1]='(' then log_str:=copy(log_str,2);
 if log_str[length(log_str)]=')' then log_str:=copy(log_str,1,length(log_str)-1);
 end;
 if ( Pos(' AND ',log_str) <> 0 ) and (Pos(' OR ',log_str) = 0 ) then
 Result := log_suche_and(log_str,str)
 else if ( Pos(' OR ',log_str) <> 0 ) and (Pos(' AND ',log_str) = 0 ) then
 Result := log_suche_or(log_str,str)
 else if ( Pos(' OR ',log_str) <> 0 ) and (Pos(' AND ',log_str) <> 0 ) then
 begin
 str_p1 := get_lgstr_part1(log_str);
 str_p2 := get_lgstr_part2(log_str);
 Result:=False;
 if copy(log_str,str_p1+1,4) = ' OR ' then
 if (log_suche(copy(log_str,1,str_p1),str) or log_suche(copy(log_str,str_p2,length(log_str)),str)) then
 Result := True
 else Result := False;
 if copy(log_str,str_p1+1,5) = ' AND ' then
 if (log_suche(copy(log_str,1,str_p1),str) and log_suche(copy(log_str,str_p2,length(log_str)),str)) then
 Result := True
 else Result := False;
 end
 else if Pos(log_str,str) <> 0 then
 Result := True
 else Result := False;
 
 end;
 |