How do I match a file name that does not end with a hyphen, using Java?
If you really, really need the regexp, this should do: .+[^-]
(at least one character (any) followed by anything BUT hypen). It can be as complicated as you want to check for possible border cases, if needed.
Why would you need a regex for that? Especially in Java. You can just check whether a hyphen is the last character of the filename.
Try (any character at least one time plus the last one any character except '-'):
.+[^-]
精彩评论