I am no expert in regular expressions - and have for hours tried several things in order to solve my problem without any luck....
I need a Regular Expression, that will match all files in a specific folder - except those ending in ".pst" ... And it must only match in the specified folder, not if a non-pst file exists in another folder..
MS Outlook default places PST files in c:/users/username/AppData/Local/Microsoft/Outlook/ - so the path must match ".*/Users/.*/AppData/Local/Microsoft/Outlook"
The files in that folder could be named:
In this case, the two files with the PST extension should not be listed/matched - but the file ending in .ost should....
Why are you using a regex to do this? Why not create a file object for the directory you want to look for files in and then call the File objects listFiles() method passing in a FilenameFilter to only accept files not ending in .pst.
The problem is, that it is to be used as an exclusion mask in a pc backup product... Unfortunately I can only specify folders to be backed up - but not specify file wildcard together with the folder name...
The only way to exclude non-PST files from backup, is to create a RegEx filter, that matches all non-PST files in the specified folder...
Sorry but you haven't added any information that makes me change my mind on the easiest way to solve this. FilenameFilters are designed for filtering file names, you can even use a regex within a FilenameFilter object if you really need to but I doubt that is necessary in your case as you are just filtering on the ".pst" extension.
I'm not clear if you only want files with a .pst extension or those without it but it's essentially the same logic with a negated return value in one of the cases.