I have made a java replica of excel's filter for jtables. It works fine, however, I can't get empty string filter to work with regexfilter, since adding "" to regexFilter would lead to show all results (also non-empty rows)
Empty cells are inserted in the table model as "" or " " via Vector.
Here's the current regex filter. Object table is the table inside the pop-up filter.
for(int i =0;i< table.getModel().getRowCount();i++) {
String val = String.valueOf(table.getModel().getValueAt(i, 1));
if(table.getModel().getValueAt(i, 0).equals(true) && (!val.equals("")|| !val.isBlank() || !val.isEmpty() || !val.equals(" "))) {
keywordCheckBox.add(table.getModel().getValueAt(i, 1));
filters.add(RowFilter.regexFilter((String)table.getModel().getValueAt(i, 1), column));
}
else if(table.getModel().getValueAt(i, 0).equals(true) && (val.equals("")|| val.isBlank() || val.isEmpty() || val.equals(" "))) {
keywordCheckBox.add(table.getModel().getValueAt(i, 1));
filters.add(RowFilter.regexFilter("/^$/", column));
}
What's the regular expression that has to be added to regexfilter to show "" values and " " only?
