![]() |
Quick regex routing question - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Quick regex routing question (/showthread.php?tid=13650) |
Quick regex routing question - El Forum - 12-01-2008 [eluser]darrenm[/eluser] Hi there I have controller that needs to take loads of arguments from a URL. The amount of arguments will vary. As the URI is going to get pretty long I'm keen to lose the 'function' part of it and re-route along the lines of: Code: /productsearch/(varying*number*of*segments) = /productsearch/listingfunction/(*everything*) Can anyone help me out with the regex specifics? many thanks. Quick regex routing question - El Forum - 12-01-2008 [eluser]darrenm[/eluser] Ok, I was being lazy. Seems to be as simple as: Code: $route['productsearch/(.)+'] = "productsearch/listing/$1"; Quick regex routing question - El Forum - 12-01-2008 [eluser]obiron2[/eluser] In the past I have had to do this where I had a whole bunch of data that needed to be passed back to the server from a clientside javascript object as the business rules were too complex to carry out without database interaction. I used the javascript serialise functions and the encoded the JSON object with URLEncode and passed the JSON object as a single parameter to the controller where I URLUnecoded it and then unserialised it so that CI would play nicely with it. You should be able to find the Javascript serialise / unserialise functions here http://www.phpguru.org/ Quick regex routing question - El Forum - 12-01-2008 [eluser]narkaT[/eluser] [quote author="darrenm" date="1228163572"]Ok, I was being lazy. Seems to be as simple as: Code: $route['productsearch/(.)+'] = "productsearch/listing/$1"; nearly ![]() Code: $route['productsearch/(.+)'] = "productsearch/listing/$1"; your regex would only "remember" the last char in the URI ![]() |