简体   繁体   中英

JTable RowFilter - case insensitive

I'm having a problem with a RowFilter , I'm trying to make it display data without it being case sensitive.

DefaultTableModel table=(DefaultTableModel)tablicaEv.getModel();
String search=jTextField1.getText();
TableRowSorter<DefaultTableModel> tr=new TableRowSorter<> (table);
tablicaEv.setRowSorter(tr);
tr.setRowFilter(RowFilter.regexFilter(search);

I tried adding "(?!)" in the RegexFilter but that only makes my table not display any data at all when I try searching. What am I doing wrong?

You probably wanted to prefix the search string with (?i) (case insensitive match).

(?!) is a "zero-width negative lookahead" matching nothing which will never match if anything follows it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM