I have a regex I need to match against a path like so: "C:\Documents and Settings\User\My Documents\ScanSnap\382893.pd~
". I need a regex that matches all paths except those ending in '~' or '.dat
'. The problem I am having is that I don't understand how to match and negate the exact string '.dat
' and only at the end of the path. i.e. I don't want to match {d,a,t}
elsewhere in the path.
I have built the regex, but need to not match .dat
[\w\s:\.\\]*[^~]$[^\.dat]
[\w\s:\.\\]*
This matches all words, whitespace, the colon, periods, and backspaces.
[^~]$[^\.dat]$
This causes matches ending in '~' to fail. It seems that I should be able to follow up with a negated match for '.dat', but the match fails in my regex tester.
I think my answer lies in grouping judging from what I've read, would someone point me in the right direction? I should add, I am using a file watching program that allows regex matching, I have only one line to specify the regex.
This entry seems similar: http://stackoverflow.com/questions/698596/regex-to-match-multiple-strings