Skip to content

Commit

Permalink
in add group dialog, extent regex "^$" to match empty field
Browse files Browse the repository at this point in the history
1. allow empty field also include entries that do not have the field at all
2. removed word boundary for more free match
  • Loading branch information
Fancy Z committed Oct 23, 2018
1 parent 389555e commit c343e16
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/java/org/jabref/model/groups/RegexKeywordGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ public RegexKeywordGroup(String name, GroupHierarchyType context, String searchF
}

private static Pattern compilePattern(String searchExpression, boolean caseSensitive) {

return caseSensitive ? Pattern.compile("\\b" + searchExpression + "\\b") : Pattern.compile(
"\\b" + searchExpression + "\\b", Pattern.CASE_INSENSITIVE);
// removed word boundary for more free match
return caseSensitive ? Pattern.compile(searchExpression) : Pattern.compile(
searchExpression, Pattern.CASE_INSENSITIVE);

}

@Override
public boolean contains(BibEntry entry) {

Optional<String> content = entry.getField(searchField);
// allow empty field also include entries that do not have the field at all
if (!content.isPresent()&&pattern.matcher("").find()) return true;
return content.map(value -> pattern.matcher(value).find()).orElse(false);
}

Expand Down

0 comments on commit c343e16

Please sign in to comment.