title: Simplify JavaScript regexp
body: <p>How can I simplify my regexp <code>(^(\w+)\/(\w+)\/(\d+)$|^(\w+)\/(\w+)\/$|^(\w+)\/(\w+)$)</code> to match examples like <code>controller/action(/id)</code>? My current regex looks so long and complex :(</p>
  
  <p>Matching examples:</p>
  
  <pre><code>controller/action
  controller/action/
  controller/action/123
  </code></pre>
  
  <p>Non-matching:</p>
  
  <pre><code>controller/
  controller/action/action
  controller/action/123/
  controller/action/123/456
  </code></pre>