dongren5293 2014-03-07 06:07
浏览 49
已采纳

Codeigniter路由不使用正则表达式

I am trying to check if a url is in given format by using regular expression. this is my code.

myurl is : example.com/123456-watch-example_video_name

$route['([0-9]+)-[watch]-[A-Z0-9_+-]'] = 'mycontroller';

It is going to 404 page. Where I am wrong, i am new to regular expression.

  • 写回答

1条回答 默认 最新

  • doumi1884 2014-03-07 06:12
    关注

    Try the below:

    $route['([0-9]+)-watch-[A-Z0-9_+-]+'] = 'mycontroller';
    

    [watch] matches one char of watch, so remove [], and [A-Z0-9_+-] matches one char too, for one and more use [A-Z0-9_+-]+

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?