iLochie
07-18-2011, 08:32 PM
Hey there, I'm looking to have some functionality similar to Twitter in that pages are loaded through ajax depending on the path that is shown in the URI hash.
For example: http://twitter.com/#!/BarackObama/following
I could just split the string by "/" but I want it to work if you enter a bunch of forward slashes as well, or none at all (only for the first forward slash), here's an example:
http://twitter.com/#///////////BarackObama/following
http://twitter.com/#BarackObama/following
http://twitter.com/#/BarackObama
The hash would be broken down into multiple parts, the first parameter (ie. BarackObama) would be the first returned value from the match, the second would be the rest of the parameters.
Here are examples of what the hash would be, and what I would like in return.
Hash:
1. http://twitter.com/#/BarackObama/following/test
2. http://twitter.com/#///////////BarackObama/following
3. http://twitter.com/#BarackObama
Returned value from RegExp match:
1. BarackObama,following/test
2. BarackObama,following
3. BarackObama
Hope that makes it pretty clear. I also have this so far, but it returns both a comma separated list, but also the original string.
/([0-9A-z]+)\/?(.*)/
For example: http://twitter.com/#!/BarackObama/following
I could just split the string by "/" but I want it to work if you enter a bunch of forward slashes as well, or none at all (only for the first forward slash), here's an example:
http://twitter.com/#///////////BarackObama/following
http://twitter.com/#BarackObama/following
http://twitter.com/#/BarackObama
The hash would be broken down into multiple parts, the first parameter (ie. BarackObama) would be the first returned value from the match, the second would be the rest of the parameters.
Here are examples of what the hash would be, and what I would like in return.
Hash:
1. http://twitter.com/#/BarackObama/following/test
2. http://twitter.com/#///////////BarackObama/following
3. http://twitter.com/#BarackObama
Returned value from RegExp match:
1. BarackObama,following/test
2. BarackObama,following
3. BarackObama
Hope that makes it pretty clear. I also have this so far, but it returns both a comma separated list, but also the original string.
/([0-9A-z]+)\/?(.*)/