开发者

regex for routing in rails 2.3.11

开发者 https://www.devze.com 2023-03-25 12:48 出处:网络
I am looking for a regex which can let开发者_如何学运维 me have a dot in the id in rails routes except the case when the format requested is xml or json, i.e.

I am looking for a regex which can let开发者_如何学运维 me have a dot in the id in rails routes except the case when the format requested is xml or json, i.e. http://www.abc.com/users/e.f.json should mean id=e.f and format=json http://www.abc.com/users/e.f should mean id=e.f

Can someone help me? Thanks!


Use this Regex:

/users\/(\w*\.\w*)(\.json|\.xml)?/

See tested code here.

0

精彩评论

暂无评论...
验证码 换一张
取 消