EllisLab text mark
Advanced Search
     
Route Problem(RegEx Issue)
Posted: 03 May 2011 03:35 AM   [ Ignore ]
Joined: 2009-10-03
103 posts

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?

 
Posted: 03 May 2011 05:04 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2010-05-13
142 posts

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$

 
Posted: 03 May 2011 05:20 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2010-01-18
10 posts

#<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.

Mr. Pickle - 03 May 2011 09:04 AM

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$

 
Posted: 03 May 2011 05:44 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2010-05-13
142 posts

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.

 
Posted: 03 May 2011 05:52 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2010-01-18
10 posts

Exactly

Mr. Pickle - 03 May 2011 09:44 AM

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.