Welcome Guest, Not a member yet? Register   Sign In
Help setting up a Regex string for CI routing
#1

[eluser]stormbytes[/eluser]
Okay, so I'm not a Regex guru Smile

I'd like a routing string that does the following:

Code:
routes['media/string' = 'media/index/$1';

where 'string' conforms to any letter/number/hyphen/underscore
combination EXCEPT one that ends in '/'
The idea is that ANY string following 'media' should be taken as an argument unless there's a slash at the end, which would mean that the string is actually a valid controller/method name.

I'd specifically like to route all requests to 'media/whatever without a slash at the end, to media/index -

thanks all your Regex Yodas out there Smile
#2

[eluser]toopay[/eluser]
[quote author="stormbytes" date="1303664005"]to any letter/number/hyphen/underscore [/quote]
Code:
routes['media/([a-zA-Z0-9_\-]+)'] = 'media/index/$1';
#3

[eluser]stormbytes[/eluser]
Hat tip!
#4

[eluser]InsiteFX[/eluser]
@strombytes

Here is a link to an Online Regex Program, If you look at the very bottom right hand side you can download a desktop version of it for your computer!

Online Regex Program

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB