title: Regular Expression, match url segments in specific order?
body: <p>I would like to match url pattern that has optional segments.</p>
  
  <p>I have URL-s like this:</p>
  
  <pre><code>subdomain.domain.com/page/pageurl/pagename/123/
  subdomain.domain.com/page/pageurl/pagename/
  subdomain.domain.com/page/pageurl/
  subdomain.domain.com/page/
  </code></pre>
  
  <p>Now I have a regex that matches all those situations:</p>
  
  <pre><code>^([a-z]+)\.domain\.com\/page(\/[a-z]+)?(\/[a-z]+)?(\/[0-9]+)?\/?$
  </code></pre>
  
  <p>But this regexs fails if you go to this URL:</p>
  
  <pre><code>subdomain.domain.com/page/123/
  </code></pre>
  
  <p>It matches this url too, and I dont want that to happen beacuse first segment should be [a-z]+ and nothing else. Now I do understand why is this happening, but I cant figure out the right regexs to suite my needs.
  I need a regexs that would match those URL-s but in order, so if first segment after page is number, it should not match...</p>
  
  <p>How would I do that? Im going crazy right now :S</p>
  
  <p>Rubural example: <a href="http://rubular.com/r/jyNIgl08Un" rel="nofollow">LINK</a></p>
  
  <p>Thanks!</p>