Question

i try to filter my JTable with this code:

String eingabe = eingabeF.getText();
RowFilter.regexFilter(".*" + eingabe + ".*", 1)

it works very well. BUT i want to filter it case-insensitive. All the values in my Column "1" have upper-cases at the beginning.

I tried this:

String eingabe = eingabeF.getText();
setRowFilter(RowFilter.regexFilter(("?i") + Pattern.quote(".*" + eingabe + ".*"), 1));

but i always get the following Error-message:

Exception in thread "AWT-EventQueue-3" java.util.regex.PatternSyntaxException: Dangling meta character '?' near index 0
?i\Q.*f.*\E

No correct solution

OTHER TIPS

First of all, the embedded case insensitive flag is "(?i)", rather than ("?i"). Secondly, you do not need to put ".*" around your string. The matcher will find it anywhere within the field as long as you do not surround it with "^" and "$". It is much simpler to initialize the filter as follows:

RowFilter.regexFilter("(?i)" + eingabe, 1);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top