• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable rowFilter - is case insensitive possible?

 
Mike Lipay
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried inserting a RowFilter into my table and it worked, so long as the filter argument matched the case in the column.



This successfully returned the rows containing "Alternator" in the Parts column. But, if I change the filter to "alt" then I do not get a hit. I tried entering Pattern.CASE_INSENSITIVE into the filter (see below), it compiles but when I execute the code no rows are returned. I checked the Java documentation on RowFilter, and there is nothing about how to set expression flags. I also tried replacing "alt" with a pattern, but that wouldn't compile.



 
Patrick Elliot
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Putting (?i) at the start of the regex makes it case insensitive.

Dirty little trick, but it works.
 
Mike Lipay
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most excellent! Thanks.
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Patrick Elliot wrote:

Which of course is simply "(?i)Alt"

Dirty little trick, but it works.

Nothing dirty about it, it's even mentioned in the Javadoc of Pattern's CASE_SENSITIVE field:
Case-insensitive matching can also be enabled via the embedded flag expression (?i).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic