thanks for your suggestion. With the ? added, it did work, but I kept having
troubles with routes where the string parameter was not followed by a number
but by another string and then by a number. So, after more testing, the
following regular expressions worked for me:

Optional string parameter followed by an optional number parameter
([a-z]{2})_([A-Z]{2})/verified/?([^\/]+)?/?(\d+)?

Examples:
en_GB/verified
en_GB/verified/what-does-this-mean
en_GB/verified/find-items/4

String parameter followed by another string followed by an optional number
([a-z]{2})_([A-Z]{2})/5/([^\/]+)/([^\/]+)/?(\d+)?

Examples:
en_GB/5/list-items-for/category-name
en_GB/5/list-items-for/category-name/2

Thanks again for pointing into the right direction.


Tim Fountain wrote:
> 
> 2009/10/9 frank.quosdorf <frank.quosd...@totuba.com>
> 
>>
>> In config.ini, the following route has been set up:
>>
>> routes.verified.type = "Zend_Controller_Router_Route_Regex"
>> routes.verified.route = "([a-z]{2})_([A-Z]{2})/verified/(.+)(/(\d+))?"
>>
> 
> 
>>
>> Apparently, parameters 3 and 4 (even including the slash in between) are
>> mapped into one request parameter (routeCaption) which is not the desired
>> result
>>
> 
> At first glance, this looks like a problem with your regular expression.
> (.+) will greedily match any character, so that will always match the
> whole
> of the rest of the URL. If you change this to (.+?), that should make it
> non-greedy, which will make it stop at the next /.
> 
> -- 
> Tim Fountain
> http://tfountain.co.uk/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Zend_Controller_Router_Route_Regex-mapping-fails-when-using-optional-parameters-tp25815360p25832209.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to