title: regular expression help matching a subdirectory for url rewrite
body: <p>So I need to capture individual sub-directories and assign each of them a reference. The reference order doesn't matter, each reference will be checked individually.
  Here is an example url:</p>
  
  <ul>
  <li><a href="http://test.com/test1/test2/happy-1200/" rel="nofollow">http://test.com/test1/test2/happy-1200/</a></li>
  </ul>
  
  <p>The URL variables (sub-directories) can also be in any order:</p>
  
  <ul>
  <li><a href="http://test.com/test1/happy-1200/test2/" rel="nofollow">http://test.com/test1/happy-1200/test2/</a></li>
  </ul>
  
  <p>here is my regex so far, but it doesn't work.:</p>
  
  <pre><code>^(?:\w+:\/\/)?(?:[\w.-]+)\/?.*$(\/[0-9a-zA-Z-]+\/){0,12}
  </code></pre>