I am trying to filter files using FilenameFilter to grep files files in a directory.
% ls -1
DirFilter.class
DirList.class
DirList.java
doctors.txt
node.l
rels.l
I am trying to filter node.l and rels.l. Filter should succeed if and only if both files are present.
I tried my regex on debuggex.com and it seems to work as expected : http://www.debuggex.com/embed/CZgVeUE2iWsNfRNG
my regex : (?s)node.l.?(?=(rels.l))
but when I run it through DirList.java filter it doesn't work..
% java DirList "(?s)node.l.?(?=(rels.l))"
<no-output>
Now I am using DirList.java from Thinking in Java http://www.cs.odu.edu/~cs476/tijava2/c10/DirList.java
Any ideas?
DirListis evaluating your regex against each file name separately, not as a single\ndelimited directory listing string as returned byls. Your regex will never match under those conditions since it never sees more than one file name at a time.