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

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -