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.
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_+-]+