Route Problem(RegEx Issue) - 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: Route Problem(RegEx Issue) (/showthread.php?tid=41248) |
Route Problem(RegEx Issue) - El Forum - 05-03-2011 [eluser]ShoeLace1291[/eluser] So i'm coding a custom forum for a website that I'm making. I have a link that I want to take the user to the last post on a thread page. The uri string looks something like this: forums/The-Board-The-Thread-Is-In/The-Title-Of-The-Thread/123/123#last Basically #last will take you to an anchor located at the last post of the thread. What I need is a regex that will accept only characters 0-9(any length) plus "#last" only at the end. Any ideas? Route Problem(RegEx Issue) - El Forum - 05-03-2011 [eluser]Mr. Pickle[/eluser] Couldn't you make it easier for yourself and have the '#last' part in a seperate uri segment: forums/The-Board-The-Thread-Is-In/The-Title-Of-The-Thread/123/123/#last Anyway, a regex for your example(any length of numbers > 0 and #last at the end) should look something like this: [0-9]{1,}#last$ Route Problem(RegEx Issue) - El Forum - 05-03-2011 [eluser]sblaas[/eluser] #<string> isn't in your "request uri" ( received server wise ) so you can't filter / regex / match on it. I'm not sure if it's possible with htaccess though but i doubt it. #last is just a html anchor. You can however substract the anchor with javascript so maybe a solution with ajax is something for ya. [quote author="Mr. Pickle" date="1304427861"]Couldn't you make it easier for yourself and have the '#last' part in a seperate uri segment: forums/The-Board-The-Thread-Is-In/The-Title-Of-The-Thread/123/123/#last Anyway, a regex for your example(any length of numbers > 0 and #last at the end) should look something like this: [0-9]{1,}#last$[/quote] Route Problem(RegEx Issue) - El Forum - 05-03-2011 [eluser]Mr. Pickle[/eluser] Then there is no problem at all is there. Just add #last after a / and if you have an html anchor #last in your page your browser will send you there. So no need for scripting at all then. Route Problem(RegEx Issue) - El Forum - 05-03-2011 [eluser]sblaas[/eluser] Exactly [quote author="Mr. Pickle" date="1304430257"]Then there is no problem at all is there. Just add #last after a / and if you have an html anchor #last in your page your browser will send you there. So no need for scripting at all then.[/quote] |