javascript - How can I remove all characters up to and including the 3rd slash in a string? -
i'm having trouble removing characters , including 3 third slash in javascript. string:
http://blablab/test the result should be:
test does know correct solution?
to last item in path, can split string on / , pop():
var url = "http://blablab/test"; alert(url.split("/").pop()); //-> "test" to specify individual part of path, split on / , use bracket notation access item:
var url = "http://blablab/test/page.php"; alert(url.split("/")[3]); //-> "test" or, if want everything after third slash, split(), slice() , join():
var url = "http://blablab/test/page.php"; alert(url.split("/").slice(3).join("/")); //-> "test/page.php"
Comments
Post a Comment