Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6866397
Votes 0
Synopsis (file) PathMatcher with regex syntax doesn't match as expected (win)
Category java:classes_nio
Reported Against
Release Fixed 7(b71)
State 10-Fix Delivered, bug
Priority: 3-Medium
Related Bugs
Submit Date 29-JUL-2009
Description
PathMather.matches(Path) don't agree with Pattern.matches(String,CharSequence) for some of predefined character classes. Please see the following test:
-----------------------------------------------------------------------
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Paths;

public class miniTest {
    public static void main(String[] args) {
        FileSystem fs = FileSystems.getDefault();
        System.out.println(fs.getPathMatcher("regex:foo\\d+").matches(Paths.get("foo012")));
        System.out.println(fs.getPathMatcher("regex:fo\\so").matches(Paths.get("fo o")));
        System.out.println(fs.getPathMatcher("regex:\\w+").matches(Paths.get("foo")));
    }
}
-----------------------------------------------------------------------

It's output is
-----------------------------------------------------------------------
false
false
false
-----------------------------------------------------------------------
while all the results of the corresponding Pattern.matches(String, CharSequence) are true
Posted Date : 2009-07-29 15:19:26.0
Work Around
N/A
Evaluation
This issue is specific to using the regex syntax on Windows. The common case, to use glob syntax, is not impacted. The issue is that the matching is done in uppercase (to be consistent with Path equals and compareTo). Unfortunately there is an oversight in that code and it is converting the regex constructs into uppercase.
Posted Date : 2009-07-29 15:28:50.0

Use the CASE_INSENSITIVE and UNICODE_CASE for windows regex match.
Posted Date : 2009-08-14 18:56:38.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang