title: Regex, optional match in url
body: <p>I spend a couple of hour with no good result (maybe my mood is not helping about it).</p>
  
  <p>I am trying to build a regex to help me match both urls:</p>
  
  <pre><code>/reservables/imagenes/4/editar/6
  /reservables/imagenes/4/subir
  </code></pre>
  
  <p>As you note above, the last segment in the first url <code>6</code> is not present at the end of the second url, because this segments is optional here. So I need to match both urls in one regex, for that, I have tried this:</p>
  
  <pre><code>reservables/(editar|imagenes)/([0-9]+)/(imagen|editar|actualizar|subir)/([0-9]+)
  </code></pre>
  
  <p>That works fine only for the first url. So, reading a few notes about regex it suggest me that I need the <code>?</code> symbol, right? So, I tried this one, but it did not work:</p>
  
  <pre><code>reservables/(editar|imagenes)/([0-9]+)/(imagen|editar|actualizar|subir)/([0-9]+)?
  </code></pre>
  
  <p>Well, I do not what I am doing wrong.</p>