title: Zend route regex, optional parameters
body: <p>I need some help about my routes in Zend (Zend1) ...</p>
  <p>I need that I can use my route like that :</p>
  <pre><code>http://mywebsite.com/myfolder/region/job/   
  http://mywebsite.com/myfolder/region/job/add  
  http://mywebsite.com/myfolder/region/job/add/page  
  http://mywebsite.com/myfolder/region/job/page   
  </code></pre>
  <p>Parameters <strong>add</strong> and <strong>page</strong> are optional ...</p>
  <p>This is what I did</p>
  <pre><code>$route = new Zend_Controller_Router_Route_Regex(
            'myfolder/([^/]+)/([^/]+)/?([^/]+)?/?([0-9]+)?',
            array('controller'    =&gt; 'myfolder','action'  =&gt; 'search'), 
            array(1 =&gt; 'region',2 =&gt; 'job', 3 =&gt; 'add', 4 =&gt; 'page'), 
            'myfolder/%s/%s/%s/%s'
           ); 
  </code></pre>
  <p>Obviously, it doesn't work ...
  What I want? I want that last the two parameters (<strong>add</strong> and <strong>page</strong>) are optional ...</p>
  <p>Can you help me? what's wrong with my regex?</p>
  <h2><strong>EDIT 1:</strong></h2>
  <p>Ok, so I tried it, but isn't ok ...<br />
  I need that parameters <strong>add</strong> and <strong>page</strong> are optional ...</p>
  <pre><code>    $route = new Zend_Controller_Router_Route(
  'myfolder/:region/:job/:add/:page',
  array(
      'controller'    =&gt; 'myfolder',
      'action'        =&gt; 'search',
      'region'        =&gt; 'XX',
      'job'        =&gt; '',
      'add'    =&gt; '',
      'page'      =&gt; 1
  ),
  array(
      'region' =&gt; '[a-zA-Z-_0-9-]+',
      'job' =&gt; '[a-zA-Z-_0-9-]+',
      'add' =&gt; '[a-zA-Z-_]+',
      'page' =&gt; '\d+'
  )
  );  
  </code></pre>
  <p>With that, this one <code>http://mywebsite.com/myfolder/region/job/page</code> doesn't work ...<br />
  <br/></p>
  <h2><strong>EDIT 2:</strong></h2>
  <p>I also tried with <code>'myfolder/:region/:job/*'</code>, but the result is same, doesn't work as I want ...<br />
  I really wonder if it is possible ...
  <br/></p>
  <h2><strong>EDIT 3:</strong>##</h2>
  <pre><code>$route = new Zend_Controller_Router_Route_Regex('myfolder/([^/]+)/([^/]+)(?:/|$)(?:(?!\d+(?:/|$))([^/]+)(?:/|$))?(?:(\d+)(?:/|$))?$',
        array('controller'    =&gt; 'myfolder', 'action' =&gt; 'recherche', 'presta' =&gt; ''), 
        array(1 =&gt; 'region',2 =&gt; 'job', 3 =&gt; 'presta', 4 =&gt; 'page'), 
        'myfolder/%s/%s/%s/%s');
  </code></pre>