I'm having troubles to create a regular expression who checks if a file has the extention .TMP so the pattern开发者_如何学C should accept any string who's not equal to (a-z 0-9 or event dots).TMP
To be clear: the matcher should only be succesfull when the file doesn't have the TMP extention.
I've allready found that I need to use (?!expression) for the "not"...
(?!.*TMP]) // is wrong ;-)
if (!filename.endsWith(".TMP")) {
/* then we found a match without using regExp */
}
"(?<!\\.TMP)\\Z"
Read: something other than ".TMP" followed by the end of the string.
It is not a answer of your question but I think you should look at Apache Common IO which have a bunch of simple methods which can do everything your commonly do. Including finding extensions. Then you simply make a if statement instead of a reg. exp.
http://commons.apache.org/io/
and see the specific java doc for getExtension: getExtension JavaDoc
精彩评论