문제

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

올바른 솔루션이 없습니다

다른 팁

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top