title: Regex to get folders and file name parts of a path
body: <p>I'm trying to parse a partial URL path into 3 groups.</p>
  
  <ul>
  <li>Group 1 - Jobs or Docs.</li>
  <li>Group 2 - The folder path (or empty if the file is directly under Jobs or Docs).</li>
  <li>Group 3 - The file name (or empty if only a folder path is specified).</li>
  </ul>
  
  <p>e.g.</p>
  
  <ul>
  <li>/Jobs/STU0001/Folder1/Sub Folder A/File Name.txt - should match on all groups.</li>
  <li>/Docs/Folder 2 - should match on groups 1 and 2.</li>
  <li>/Docs/Another File.doc - should match on groups 1 and 3.</li>
  </ul>
  
  <p>I've tried the following (and other slight variations of the same) but just can't get one pattern to suit all the possible inputs.</p>
  
  <p><code>^/?(Jobs|Docs)/(.*)/(.+\..+)?$</code> - Works for 1, not 2 or 3</p>
  
  <p><code>^/?(Jobs|Docs)/(.*)/?(.+\..+)?$</code> - Works for 2, not 1 or 3</p>
  
  <p>For info:</p>
  
  <ul>
  <li>File names will always have an extension (and therefore a full stop/period).</li>
  <li>Folder names will never have a full stop/period in their name.</li>
  </ul>