title: Regular Expression for last folder in path
body: <p>I've been trying to capture the last folder in a folder path using regular expressions in C# but am just too new to this to figure this out.  For example if I have C:\Projects\Test then the expression should return Test.  If I have H:\Programs\Somefolder\Someotherfolder\Final then the result should be Final.  I've tried the below code but it just blows up.  Thanks for any help.</p>
  
  <pre><code>string pattern = ".*\\([^\\]+$)";
  Match match = Regex.Match("H:\\Projects\\Final", pattern, RegexOptions.IgnoreCase);
  </code></pre>