United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6866397 (file) PathMatcher with regex syntax doesn't match as expected (win)
6866397 : (file) PathMatcher with regex syntax doesn't match as expected (win)

Details
Type:
Bug
Submit Date:
2009-07-29
Status:
Resolved
Updated Date:
2011-01-19
Project Name:
JDK
Resolved Date:
2009-08-28
Component:
core-libs
OS:
generic
Sub-Component:
java.nio
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:
7

Related Reports

Sub Tasks

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

                                    

Comments
EVALUATION

Use the CASE_INSENSITIVE and UNICODE_CASE for windows regex match.
                                     
2009-08-14
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.
                                     
2009-07-29



Hardware and Software, Engineered to Work Together