Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
38
rated 0 times [  42] [ 4]  / answers: 1 / hits: 20982  / 9 Years ago, thu, july 9, 2015, 12:00:00

Okay I have this



var URL = http://stackoverflow.com/questions/10767815/remove-everything-before-the-last-occurrence-of-a-character;
console.log(URL.substring(URL.lastIndexOf(/)));


Gives you /remove-everything-before-the-last-occurrence-of-a-character



How do I get http://stackoverflow.com/questions/10767815/


More From » javascript

 Answers
44

Here you are:





var URL = http://stackoverflow.com/questions/10767815/remove-everything-before-the-last-occurrence-of-a-character;
alert(URL.substring(0, URL.lastIndexOf(/) + 1));





Hope this helps.


[#65870] Tuesday, July 7, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mackenzihannal

Total Points: 548
Total Questions: 96
Total Answers: 96

Location: Lithuania
Member since Fri, Sep 4, 2020
4 Years ago
;