title: Simple C# regex
body: <p>I have a regex I need to match against a path like so: "<code>C:\Documents and Settings\User\My Documents\ScanSnap\382893.pd~</code>".  I need a regex that matches all paths except those ending in '~' or '<code>.dat</code>'.  The problem I am having is that I don't understand how to match and negate the exact string '<code>.dat</code>' and only at the end of the path.  i.e. I don't want to match <code>{d,a,t}</code> elsewhere in the path.</p>
  
  <p>I have built the regex, but need to not match .dat</p>
  
  <p><code>[\w\s:\.\\]*[^~]$[^\.dat]</code></p>
  
  <p><code>[\w\s:\.\\]*</code>  This matches all words, whitespace, the colon, periods, and backspaces.
  <code>[^~]$[^\.dat]$</code>  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.</p>
  
  <p>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.</p>
  
  <p>This entry seems similar: <a href="https://stackoverflow.com/questions/698596/regex-to-match-multiple-strings">Regex to match multiple strings</a></p>