package net.sf.jabref.model.search.rules;

public class SearchRules {

    /**
     * Returns the appropriate search rule that fits best to the given parameter.
     */
    public static SearchRule getSearchRuleByQuery(String query, boolean caseSensitive, boolean regex) {
        // this searches specified fields if specified,
        // and all fields otherwise
        SearchRule searchExpression = new GrammarBasedSearchRule(caseSensitive, regex);
        if (searchExpression.validateSearchStrings(query)) {
            return searchExpression;
        } else {
            return getSearchRule(caseSensitive, regex);
        }
    }

    private static SearchRule getSearchRule(boolean caseSensitive, boolean regex) {
        if (regex) {
            return new RegexBasedSearchRule(caseSensitive);
        } else {
            return new ContainBasedSearchRule(caseSensitive);
        }
    }

}

@@ -36,16 +36,64 @@
 rules;%0A%0A
+import net.sf.jabref.model.strings.StringUtil;%0A%0A
 public c
@@ -306,32 +306,146 @@
 oolean regex) %7B%0A
+        if (StringUtil.isBlank(query)) %7B%0A            return new ContainBasedSearchRule(caseSensitive);%0A        %7D%0A%0A
         // this 

Fix logged warning when searching for nothing (i.e. clear search) (#2045)