wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes JTable rowFilter - is case insensitive possible? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable rowFilter - is case insensitive possible?" Watch "JTable rowFilter - is case insensitive possible?" New topic
Author

JTable rowFilter - is case insensitive possible?

Mike Lipay
Ranch Hand

Joined: Sep 11, 2007
Posts: 171
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

Joined: Jun 04, 2010
Posts: 1


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

Dirty little trick, but it works.
Mike Lipay
Ranch Hand

Joined: Sep 11, 2007
Posts: 171
Most excellent! Thanks.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19684
    
  20

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).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable rowFilter - is case insensitive possible?