title: C# Regex to Get file name without extension?
body: <p>I want to use regex to get a filename without extension. I'm having trouble getting regex to return a value. I have this:</p>
  
  <pre><code>string path = @"C:\PERSONAL\TEST\TESTFILE.PDF";
  var name = Regex.Match(path, @"(.+?)(\.[^\.]+$|$)").Value;
  </code></pre>
  
  <p>In this case, <code>name</code> always comes back as <code>C:\PERSONAL\TEST\TESTFILE.PDF</code>. What am I doing wrong, I think my search pattern is correct?</p>
  
  <p>(I am aware that I could use <code>Path.GetFileNameWithoutExtension(path);</code>but I specifically want to try using regex)</p>