![]() |
RegEx driving me mad - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: RegEx driving me mad (/showthread.php?tid=42460) |
RegEx driving me mad - El Forum - 06-08-2011 [eluser]Y0shi[/eluser] Hello guys, I have some problems with the RegEx from the routes files. I think it should be simple but I cant manage to get it working... I've a table called _seo where everything belonging to uris is stored. For example my user can edit a page like /article/showarticle/1 to /homesite and it will be displayed. But now, since a new feature should be, I need a regex which still proceeds the parameters to the controllers. In other words: I want to implement a feature which allows multible sites like: /article/showarticle/1/1 /article/showarticle/1/2 /article/showarticle/1/3 ... and so on That should be: /homesite/1 /homesite/2 /homesite/3 Is there a very general RegEx a solution for this problem? Thanks for your help in advance. Regards. RegEx driving me mad - El Forum - 06-08-2011 [eluser]Seb[/eluser] Hello, Take a look at http://ellislab.com/codeigniter/user-guide/general/routing.html. You can try something like Code: $route['homesite/(\d+)'] = "article/showarticle/1/$1"; RegEx driving me mad - El Forum - 06-08-2011 [eluser]Y0shi[/eluser] Thanks! Yeah that's what I know too, but my routes are dynamicly loaded. So I need a general term for anything/attributes -> controller/attributes RegEx driving me mad - El Forum - 06-08-2011 [eluser]Seb[/eluser] Well what about Code: $route['([a-z]+)/(\d+)'] = "article/showarticle/$1/$2"; But do you mean you load and populate your routes from a database for every request ? RegEx driving me mad - El Forum - 06-08-2011 [eluser]Y0shi[/eluser] I'll give it a try ![]() Yeah I do so ... needed to make user routes happen :/ |