title: Extracting segment path parameters from url
body: <p>I have been trying to figure out how I could extract the segment path parameters from a REST url.<br>
  We know that REST url parameters can be represented in two ways:</p>
  
  <ol>
  <li>As part of the path</li>
  <li>As a query parameter.</li>
  </ol>
  
  <p>When a user clicks on a link from our website we capture the link and the subsequent path traversed using Google Api and save it in our database as three parts:  </p>
  
  <ol>
  <li>The base url</li>
  <li>The segment path parameters (if any)</li>
  <li>The query parameters (if any).</li>
  </ol>
  
  <p>For example: <code>http://www.test.com/article/12345?order=2</code></p>
  
  <p>is seperated into:</p>
  
  <p>baseurl : <code>http://www.test.com/article</code><br>
  segment path parameters : <code>12345</code><br>
  query parameters : <code>order=2</code>  </p>
  
  <p>I am aware of how I can separate the segments out of a url, but my question is how do I know if in a given url a segment is a parameter or not. For example in the above example "12345" could be a REST parameter or simply part of the path. How does one distinguish that</p>